p***@qq.com
p***@qq.com
  • 发布:2016-11-29 17:19
  • 更新:2016-11-29 22:26
  • 阅读:1003

tab bar 如何由一頁跳到另一頁

分类:MUI
mui


我想由[首頁]按一下連結,就跳到[設罝]頁面,如何做呢,請教高人指點.

2016-11-29 17:19 负责人:无 分享
已邀请:
赵梦欢

赵梦欢 - 专注前端,乐于分享!

使用事件触发,例如hello mui中例子改改:

<nav class="mui-bar mui-bar-tab">  
    <a class="mui-tab-item mui-active" href="#tabbar">  
        <span class="mui-icon mui-icon-home"></span>  
        <span class="mui-tab-label">首页</span>  
    </a>  
    <a class="mui-tab-item" href="#tabbar-with-chat">  
        <span class="mui-icon mui-icon-email"><span class="mui-badge">9</span></span>  
        <span class="mui-tab-label">消息</span>  
    </a>  
    <a class="mui-tab-item" href="#tabbar-with-contact">  
        <span class="mui-icon mui-icon-contact"></span>  
        <span class="mui-tab-label">通讯录</span>  
    </a>  
    <a id="goSetting" class="mui-tab-item" href="#tabbar-with-map">  
        <span class="mui-icon mui-icon-gear"></span>  
        <span class="mui-tab-label">设置</span>  
    </a>  
</nav>

然后调用这个:

var goSetting= document.getElementById("goSetting");  
//模拟首页点击  
mui.trigger(goSetting, 'tap');  
//切换选项卡高亮  
var current = document.querySelector(".mui-bar-tab>.mui-tab-item.mui-active");  
if (goSetting!== current) {  
    current.classList.remove('mui-active');  
    goSetting.classList.add('mui-active');  
}
p***@qq.com

p***@qq.com (作者)

Uncaught ReferenceError: defaultTab is not defined at book.html:982

defaultTab 沒有定義, 請問要如何設定??

  • 赵梦欢

    刚有个没注意。。。

    2016-11-29 22:26

  • p***@qq.com (作者)

    tab 的顏色亮了,但是內容沒有相對轉變,....???

    2016-11-29 23:22

该问题目前已经被锁定, 无法添加新回复