国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

sencha touch 模仿tabpanel導航欄TabBar的實例代碼

2019-11-20 21:51:00
字體:
來源:轉載
供稿:網友

基于sencha touch 2.2所寫

代碼:

復制代碼 代碼如下:

/*
*模仿tabpanel導航欄
*/
Ext.define('ux.TabBar', {
    alternateClassName: 'tabBar',
    extend: 'Ext.Toolbar',
    xtype: 'tabBar',
    config: {
        docked: 'bottom',
        cls: 'navToolbar',
        layout: {
            align: 'stretch'
        },
        defaults: {
            flex: 1
        },
        //被選中的按鈕
        selectButton: null
    },
    initialize: function () {
        var me = this;
        me.callParent();
        //監聽按鈕點擊事件
        me.on({
            delegate: '> button',
            scope: me,
            tap: 'onButtonTap'
        });
    },
    //更新被選中按鈕
    updateSelectButton: function (newItem, oldItem) {
        console.log(oldItem);
        if (oldItem) {
            oldItem.removeCls('x-tabBar-pressing');
        }
        if (newItem) {
            newItem.addCls('x-tabBar-pressing');
        }
    },
    //當按鈕被點擊時
    onButtonTap: function (button) {
        this.setSelectButton(button);
    },
    /**
    * @private
    *執行添加項,調用add方法后自動執行
    */
    onItemAdd: function (item, index) {
        if (!this.getSelectButton() && item.getInitialConfig('selected')) {
            this.setSelectButton(item);
        }
        this.callParent(arguments);
    }
});

需要的css:

復制代碼 代碼如下:

.navToolbar {
    padding:0;
}
.navToolbar .x-button {
    border:0;
    margin:0;
    border-right:1px solid #585B5B;
    border-radius:0;
    padding:0;
}
.navToolbar .x-button .x-button-label {
    font-weight:normal;
    color:White;
    font-size:0.6em;
}
.navToolbar .x-tabBar-pressing {
    background-image:none;
    background-color:#0f517e;
    background-image:-webkit-gradient(linear,50% 0%,50% 100%,color-stop(0%,#0a3351),color-stop(10%,#0c4267),color-stop(65%,#0f517e),color-stop(100%,#0f5280));
    background-image:-webkit-linear-gradient(top,#0a3351,#0c4267 10%,#0f517e 65%,#0f5280);
    background-image:-moz-linear-gradient(top,#0a3351,#0c4267 10%,#0f517e 65%,#0f5280);
    background-image:-o-linear-gradient(top,#0a3351,#0c4267 10%,#0f517e 65%,#0f5280);
    background-image:linear-gradient(top,#0a3351,#0c4267 10%,#0f517e 65%,#0f5280);
}

使用:

復制代碼 代碼如下:

Ext.define('app.view.MyBar', {
    alternateClassName: 'myBar',
    extend: 'ux.TabBar',
    xtype: 'myBar',
    config: {
        items: [
        {
            xtype: 'button',
            text: '問卷調查',
            //只有第一個設置的屬性有效
            selected: true
        },
        {
            xtype: 'button',
            text: '我的積分'
        },
        {
            xtype: 'button',
            text: '開獎大廳'
        },
        {
            xtype: 'button',
            text: '幸運號碼'
        },
        {
            xtype: 'button',
            text: '更多'
        }]
    }
});

效果圖:

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 安乡县| 清水河县| 海门市| 梁河县| 葫芦岛市| 新平| 永善县| 新巴尔虎左旗| 砚山县| 股票| 雷波县| 呼玛县| 阿尔山市| 桂林市| 许昌县| 屯留县| 娄烦县| 南木林县| 库车县| 西乌珠穆沁旗| 志丹县| 佳木斯市| 湘阴县| 五台县| 兴安县| 昭觉县| 游戏| 正蓝旗| 荣昌县| 庆阳市| 库伦旗| 泗洪县| 汾阳市| 藁城市| 石屏县| 米林县| 疏勒县| 镇宁| 仪征市| 苍梧县| 丰镇市|