Ext button 点击前后样式的修改

在这里插入图片描述
点击之前的按钮颜色
在这里插入图片描述
点击之后的颜色

Ext.create('Ext.Button', {
    text    : 'Dynamic Handler Button',
    renderTo: Ext.getBody(),
     style: {
                  backgroundColor: '#26adaf',
                  color: 'white',
                  borderRadius: '4px'
                },
                 _visited: true,
                listeners: {
                  click: function (btn) {
                    if (!btn._visited) {
                      btn._visited = true;
                       btn.getEl().setStyle({
                       backgroundColor: '#26adaf',
                       color: 'white',
                       borderRadius: '4px'
                       });
                    } else {
                      btn._visited = false;//如果注释了这里就只能改变一次,需要和上面的交换起来用
                      btn.getEl().setStyle({
                        backgroundColor: '',
                        color: '#49A9EE',
                        borderRadius: '4px',
                        borderColor: '#49A9EE'
                      });
                     /* Ext.getCmp('btn2').setStyle({
                        backgroundColor: '#26adaf',
                        color: 'white',
                        borderRadius: '4px'
                      });
                      Ext.getCmp('btn1').setStyle({
                        backgroundColor: '#26adaf',
                        color: 'white',
                        borderRadius: '4px'
                      });*/
                    }
                  }
                },
    handler : function() {
        // this button will spit out a different number every time you click it.
        // so firstly we must check if that number is already set:
        if (this.clickCount) {
            // looks like the property is already set, so lets just add 1 to that number and alert the user
            this.clickCount++;
            alert('You have clicked the button "' + this.clickCount + '" times.\n\nTry clicking it again..');
        } else {
            // if the clickCount property is not set, we will set it and alert the user
            this.clickCount = 1;
            alert('You just clicked the button for the first time!\n\nTry pressing it again..');
        }
    }
});
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值