查看mui官网上面的例子,会看到有多种tab 选项卡的例子,我就写下我用到的tab选项卡。写了个简单的例子,效果如下图
主页面的代码
<nav class="mui-bar mui-bar-tab"><a class="mui-tab-item mui-active" href="main.html"><span class="mui-icon mui-icon-home"></span><span class="mui-tab-label">首页</span></a><a class="mui-tab-item" href="main2.html"><span class="mui-icon mui-icon-phone"></span><span class="mui-tab-label">电话</span></a><a class="mui-tab-item" href="message.html"><span class="mui-icon mui-icon-star"></span><span class="mui-tab-label">功能</span></a><a class="mui-tab-item"><span class="mui-icon mui-icon-email"></span><span class="mui-tab-label">邮件</span></a><a class="mui-tab-item"><span class="mui-icon mui-icon-gear"></span><span class="mui-tab-label">设置</span></a></nav>
js 代码
(function () {//初始化mui.init();var subpages = ['main.html', 'main2.html', 'message.html'];var subpage_style = {top: '0px',bottom: '51px'};//创建子页面,首个选项卡页面显示,其它均隐藏;mui.plusReady(function() {var self = plus.webview.currentWebview();for(var i = 0; i < 1; i++) { // 如果i等于所有的子页面的话,那么子页面的js都会去执行var temp = {};var sub = plus.webview.create(subpages[i], subpages[i], subpage_style);if(i > 0) {sub.hide();} self.append(sub);}});var activeTab = subpages[0];//选项卡点击事件mui('.mui-bar-tab').on('tap', 'a', function(e) {var targetTab = this.getAttribute('href');console.log(targetTab)if (targetTab == activeTab) {return;}var self = plus.webview.currentWebview();var sub = plus.webview.create(targetTab, targetTab, subpage_style);self.append(sub);
// //隐藏当前;plus.webview.hide(activeTab);//这里应该是关闭页面,不知道隐藏与关闭区别有多大
// //更改当前活跃的选项卡activeTab = targetTab;});})()