From e487760d6c8eb131aea96518869568f3c09c6914 Mon Sep 17 00:00:00 2001 From: treecat Date: Wed, 17 Aug 2022 11:01:00 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-9408=20fix:=E6=8C=89=E9=92=AE=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=9B=BE=E6=A0=87=E7=9A=84=E6=9C=80=E7=BB=88?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/base/button/demo.button.js | 6 ---- src/base/single/button/buttons/button.js | 39 +++++++++--------------- 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/demo/js/base/button/demo.button.js b/demo/js/base/button/demo.button.js index 39b27b716..420a47d77 100644 --- a/demo/js/base/button/demo.button.js +++ b/demo/js/base/button/demo.button.js @@ -376,12 +376,6 @@ Demo.Button = BI.inherit(BI.Widget, { this.loaded(); }, 5 * 1000); }, - }, { - type: "bi.button", - text: "图标的实现交给其他框架", - icon(element) { - element.append("🧙"); - }, }]; return { diff --git a/src/base/single/button/buttons/button.js b/src/base/single/button/buttons/button.js index f9aa8586e..7a8ba672d 100644 --- a/src/base/single/button/buttons/button.js +++ b/src/base/single/button/buttons/button.js @@ -91,29 +91,20 @@ } var iconInvisible = !o.loading && !o.iconCls; - if (BI.isPlainObject(o.icon)) { + if (BI.isPlainObject(o.icon) && !o.loading) { this.icon = BI.createWidget(o.icon); - o.loading ? (this.icon.loading && this.icon.loading()) - : (this.icon.loaded && this.icon.loaded()); } else { - if (!o.loading && BI.isFunction(o.icon)) { - this.icon = BI.createWidget({ - type: "bi.layout", - }); - o.icon(this.icon.element); - } else { - this.icon = BI.createWidget({ - type: "bi.icon_label", - cls: o.loading ? loadingCls : (o.iconCls || o.icon), - width: this._const.iconWidth, - height: lineHeight, - lineHeight: lineHeight, - // 不设置,自定义按钮无法居中 - iconWidth: o.iconWidth, - iconHeight: o.iconHeight, - invisible: iconInvisible, - }); - } + this.icon = BI.createWidget({ + type: "bi.icon_label", + cls: o.loading ? loadingCls : (o.iconCls || o.icon), + width: this._const.iconWidth, + height: lineHeight, + lineHeight: lineHeight, + // 不设置,自定义按钮无法居中 + iconWidth: o.iconWidth, + iconHeight: o.iconHeight, + invisible: iconInvisible, + }); } // 用于 whiteSpace @@ -140,12 +131,12 @@ tgap: o.iconPosition === "top" ? o.iconGap : 0, bgap: o.iconPosition === "bottom" ? o.iconGap : 0, }; - var items = [this.icon, BI.extend({ el: this.text }, gapContainer)]; + var items = [this.icon, BI.extend({el: this.text}, gapContainer)]; if (isVertical(o.iconPosition)) { layoutType = "bi.vertical"; } if (o.iconPosition === "right" || o.iconPosition === "bottom") { - items = [BI.extend({ el: this.text }, gapContainer), this.icon]; + items = [BI.extend({el: this.text}, gapContainer), this.icon]; } // bi.center_adapt 作用:让 hgap 不影响 iconGap。 BI.createWidget({ @@ -170,7 +161,7 @@ }); if (o.minWidth > 0) { - this.element.css({ "min-width": o.minWidth / BI.pixRatio + BI.pixUnit }); + this.element.css({"min-width": o.minWidth / BI.pixRatio + BI.pixUnit}); } },