Browse Source

DESIGN-4069 feat: button 增加 setIcon 属性

research/test
treecat 3 years ago
parent
commit
7b2a43c582
  1. 15
      demo/js/base/button/demo.button.js
  2. 11
      src/base/single/button/buttons/button.js

15
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 () {

11
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);
},

Loading…
Cancel
Save