如何使用pressedcls更改extjs4中按钮的背景图像?

use*_*934 6 html javascript css button extjs4

我使用extjs4创建了一个切换按钮组.当我按下一个按钮时,其他按钮变为未按下.然后我想在按下后更改按钮的背景图像.所以我使用"pressedCls".代码:

Ext.define('Crm.view.CrmNavi', {
    extend: 'Ext.toolbar.Toolbar',
    height: 27,

    initComponent: function() {
        var me = this;

        Ext.applyIf(me, {
            items: [
                {
                    cls: 'navi_btn',
                    overCls: 'navi_btn_over',
                    pressedCls: 'navi_btn_pressed',
                    xtype: 'button',
                    height: 24,
                    flex: 4,
                    html: 'button one'
                    toggleGroup: 'crmNaviBtnGroup',
                    enableToggle: true,
                    pressed: true
                },
                {
                    cls: 'navi_btn',
                    overCls: 'navi_btn_over',
                    pressedCls: 'navi_btn_pressed',
                    xtype: 'button',
                    height: 24,
                    flex: 4,
                    margin: '0 0 0 0',
                    html: 'button two',
                    toggleGroup: 'crmNaviBtnGroup',
                    enableToggle: true
                 }
            ]
        });
    }
});

//-----------------------------------------------------------
.navi_btn{
    font-family: MicroSoft YaHei;
    font-weight: 5;
    font-size: 15px;
    text-align: center;
    color: #006f61; 
}
.navi_btn_over{
    font-family: MicroSoft YaHei;
    font-weight: 3;
    font-size: 15px;
    text-align: center;
    color: #ffffff;
    background-image: url("images/crmNaviBtnPressed_bg.png");
    background-repeat: repeat-x;
}
.x-navi_btn_pressed{
    font-family: MicroSoft YaHei;
    font-weight: 3;
    font-size: 15px;
    text-align: center;
    color: #ffffff;
    background-image: url("images/crmNaviBtnPressed_bg.png");
    background-repeat: repeat-x;
}
Run Code Online (Sandbox Code Playgroud)

// ------------------------------------------------ ------------------

它适用于谷歌浏览器.但在IE8上,背景图像设置不起作用(字体设置效果很好).那么,有什么设置可以解决这个问题吗?

JSu*_*uar 0

  1. 将悬停效果应用于 ExtJs 中的容器

    可惜你不能使用 CSS。如果可以的话,那么 overCls 将是正确的选择: http://docs.sencha.com/ext-js/4-1/# !/api/Ext.AbstractComponent-cfg-overCls

    除此之外,你的方法非常接近。将样式对象应用到 el 上不会执行任何操作,因为 Ext 不知道您这样做了。相反,您想调用 setStyle 或 applyStyles

    http://docs.sencha.com/ext-js/4-1/#!/api/Ext.dom.Element-method-applyStyles

    http://docs.sencha.com/ext-js/4-1/#!/api/Ext.dom.Element-method-setStyle

  2. 另一个可能解决方案的问题:Ext.Button 'overCls' notworking in IE