diff --git a/demo/js/base/button/demo.button.js b/demo/js/base/button/demo.button.js index 400559566..056564c9f 100644 --- a/demo/js/base/button/demo.button.js +++ b/demo/js/base/button/demo.button.js @@ -376,6 +376,21 @@ Demo.Button = BI.inherit(BI.Widget, { plain: true, disabled: true } + }, { + el: { + type: "bi.button", + iconCls: "plus-font", + text: "点我,更改图标", + handler() { + this.i = this.i === undefined ? 0 : ++this.i; + const arr = ["text-background-font", "check-mark-ha-font", "close-font", "search-font", "date-change-h-font"]; + if(this.i >= arr.length) { + this.i = 0; + } + this.setIcon(arr[this.i]); + }, + height: 24 + } }]; // BI.each(items, function (i, item) { // item.el.handler = function () { diff --git a/src/base/single/button/buttons/button.js b/src/base/single/button/buttons/button.js index 78e910f7c..0ba1468b4 100644 --- a/src/base/single/button/buttons/button.js +++ b/src/base/single/button/buttons/button.js @@ -77,8 +77,8 @@ } if (BI.isKey(o.iconCls)) { this.icon = BI.createWidget({ - type: "bi.icon_label", - cls: o.iconCls, + type: "bi.icon_change_button", + iconCls: o.iconCls, width: this._const.iconWidth, height: lineHeight, lineHeight: lineHeight @@ -195,6 +195,13 @@ } }, + setIcon: function (iconCls) { + if (this.icon) { + this.options.iconCls = iconCls; + this.icon.setIcon(iconCls); + } + }, + doRedMark: function () { this.text.doRedMark.apply(this.text, arguments); },