diff --git a/demo/js/base/button/demo.button.js b/demo/js/base/button/demo.button.js index 651d98e4a..981683e84 100644 --- a/demo/js/base/button/demo.button.js +++ b/demo/js/base/button/demo.button.js @@ -381,6 +381,10 @@ Demo.Button = BI.inherit(BI.Widget, { text: "文字偏左的按钮", textAlign: "left", width: 200, + }, { + type: "bi.button", + text: "小于最小宽度的按钮", + width: 50, }]; return { diff --git a/src/base/single/button/buttons/button.js b/src/base/single/button/buttons/button.js index 94b590f84..9965b1ff1 100644 --- a/src/base/single/button/buttons/button.js +++ b/src/base/single/button/buttons/button.js @@ -107,8 +107,9 @@ }); } - // 用于 whiteSpace - var textWidth = iconInvisible && o.width ? o.width - o.hgap * 2 : null; + // 用户可能设置的 width 小于按钮的最小宽度 + var actualWidth = (o.minWidth > 0 && o.width < o.minWidth) ? o.minWidth : o.width; + var textWidth = iconInvisible && o.width ? actualWidth - o.hgap * 2 : null; if (BI.isNotNull(o.textWidth)) { // textWidth 需要减去图标 textWidth = o.textWidth - (iconInvisible || isVertical(o.iconPosition) ? 0 : this._const.iconWidth); diff --git a/typescript/base/single/button/buttons/button.ts b/typescript/base/single/button/buttons/button.ts index 55f62ef8b..9b357ae0c 100644 --- a/typescript/base/single/button/buttons/button.ts +++ b/typescript/base/single/button/buttons/button.ts @@ -14,6 +14,9 @@ export declare class Button extends BasicButton { block?: boolean; // 是否块状显示,即不显示边框,没有最小宽度的限制 clear?: boolean; // 是否去掉边框和背景 ghost?: boolean; // 是否幽灵显示, 即正常状态无背景 + iconGap?: number; + iconPosition?: string; + textWidth?: number; } & AbstractLabel['props'] & IconLabel['props'] & BasicButton['props']; text: Label; @@ -26,4 +29,12 @@ export declare class Button extends BasicButton { doHighLight(...args: any[]): void; unHighLight(...args: any[]): void; + + loading(): void; + + loaded(): void; + + setIcon(iconCls: string): void; + + isLoading(): boolean; }