自问自答,虽然很占内存 方法时是多开webview 1.添加A1为index.html的子页 为index.html注册跳转事件 document.addEventListener('gohome1', function(event) { //传入要跳转的参数页 targetTab= event.detail.tiao; //跳转代码 if(targetTab==activeTab){ return; } //更换标题 //title.innerHTML = this.querySelector('.mui-tab-label').innerHTML; //显示目标选项卡 plus.webview.show(targetTab); //隐藏当前选项卡 plus.webview.hide(activeTab); //更改活跃的选项卡 activeTab=targetTab; //切换第一个选项卡按钮高亮 var defaultTab = document.getElementById("defaultTab"); //模拟首页点击 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'); } }); 在子页A调用跳转至A1(如点击id为"comment"的按钮跳转A1) btn.addEventListener('tap',function () { //获得主页面的webview var main = plus.webview.currentWebview().parent(); //触发主页面的gohome1事件 mui.fire(main,"gohome1",{ tiao:"A1.html" }); });
1 个回复
7***@qq.com (作者)
自问自答,虽然很占内存
方法时是多开webview
1.添加A1为index.html的子页
为index.html注册跳转事件
btn.addEventListener('tap',function () {
//获得主页面的webview
var main = plus.webview.currentWebview().parent();
//触发主页面的gohome1事件
mui.fire(main,"gohome1",{
tiao:"A1.html"
});
});