在mui中,底部导航栏的切换是入门的,但通过传统的页面跳转会比较麻烦,所以此方法实现只是其中一种,还有其他方法在Dcloud官方网站上也有举例。
mui.plusReady(function(){
var page = ['1.html','2.html','3.html','4.html'
];
//创建4个窗口
var ws = plus.webview.currentWebview();
var style = {
top:"0px",
bottom:"50px"
};
//循环每一个页面
for (var i = 0; i < page.length; i++) {
var item = plus.webview.create( page[i], page[i],style);
item.hide();//加载完成后,先隐藏此页面
ws.append(item);//将页面添加到webview对象中
}
//显示每一个页面
mui(".mui-bar-tab").on("tap",'a',function(){
var href = this.getAttribute("href");
plus.webview.show(href);//显示每次显示所在的页面
});
});