Mui怎么用代码切换选项卡高亮啊?

是这样,环境是当用户收到推送然后监听click事件,点击推送进入应用后应该自动跳转到消息选项卡

现在我可以切换选项卡的显示和隐藏,但是下方选项卡的高亮显示还是原来的,不知道怎么切换选项卡图标高亮的切换,用mui.fire(index,'gohome')也不行

这是选项卡

<nav class="mui-bar-dibu mui-bar-tab has-bottombar bottom-menu-fixed">

<a class="mui-tab-item" href="zhuangtai.html">

<span class="mui-icon iconfont icon-jihua1"></span>

<span class="mui-tab-label">状态</span>

</a>

<a class="mui-tab-item" href="zixiqiang.html">

<span class="mui-icon iconfont icon-xuexi"></span>

<span class="mui-tab-label">自习墙</span>

</a>

<a class="mui-tab-item" href="xiaoxi.html" id="xiaoxi">

<span class="mui-icon iconfont icon-xiaoxi2"><span class="iconfont icon-dian" id="xiaoxi-1" style="position: relative; left: -9px; top: -9px; color: #DD524D; display: none;"></span></span>



<span class="mui-tab-label">消息</span>

</a>

<a class="mui-tab-item mui-active" href="wode.html">

<span class="mui-icon iconfont icon-profile"></span>

<span class="mui-tab-label">我的</span>

</a>

</nav>

\n

这是切换选项卡的部分,可以控制选项卡的显示和隐藏,但是选项卡上的高亮图标没变

function tabturn(targettab) {

var targetTab = targettab;

if (targetTab == activeTab) {

return;

}

if (mui.os.ios || aniShow[targetTab]) {

plus.webview.show(targetTab);

} else {

var temp = {};

temp[targetTab] = "true";

mui.extend(aniShow, temp);

plus.webview.show(targetTab, "fade-in", 300);

}

plus.webview.hide(activeTab);

activeTab = targetTab;

var defaultTab = document.getElementById("defaultTab");

//模拟首页点击

mui.trigger(defaultTab, 'tap');

//切换选项卡高亮

var current = document.querySelector(".mui-bar-tab>.mui-tab-item.mui-active");

if (defaultTab !== current) {

current.classList.remove('mui-active');

defaultTab.classList.add('mui-active');

}

}

\n

2018-11-08 12:23 添加评论 分享
已邀请:
0

约学

赞同来自:

已解决,给a标签那一行加个id让它等于href,然后获取传入的页面就可以了

var current = document.querySelector(".mui-bar-tab>.mui-tab-item.mui-active");
var defaultTab=document.getElementById(targetTab);
if (defaultTab !== current) {
current.classList.remove('mui-active');
defaultTab.classList.add('mui-active');
}
\n

要回复问题请先登录注册