更改SENCHA TOUCH 2中按钮的图标类

Changing Icon class of a button in SENCHA TOUCH 2

本文关键字:图标 按钮 SENCHA TOUCH 更改      更新时间:2023-09-26

当点击按钮时,我想将按钮的图标类(iconCls:'arrow_down')更改为另一个图标类(图标Cls:'arrow_up')。请帮帮我。

Sencha组件中的每个属性都会自动获得其getter和setter函数:您只需要在按钮上调用setIconCls()即可更改图标。

{
    xtype: 'button',
    iconCls: 'arrow_down',
    listeners: {
        tap: function() {
            if (this.getIconCls() === 'arrow_down') {
                this.setIconCls('arrow_up');
            } else {
                this.setIconCls('arrow_down');
            }
        }
    }
}

工作示例:https://fiddle.sencha.com/?fiddle=bps#fiddle/bps