原创

MUI-关闭某一页面-关闭所有页面

function closeLoginInstance() {//关闭某一页
var loginwb = plus.webview.getWebviewById('login.html') || plus.webview.getWebviewById('login');
if(loginwb) {
loginwb.close();
console.log('关闭登陆页');
} else {
console.log('关闭登陆页不存在');
}
}


关闭所有页面
var all = plus.webview.all();
var current = plus.webview.currentWebview().id;
var settingObj = plus.webview.getWebviewById('setting') || plus.webview.getWebviewById('setting.html');
for(var i = 0, len = all.length; i < len; i++) {
console.log('逐个关闭页面0:' + JSON.stringify(settingObj)); //打印出setting;
if(all[i].id !== current && all[i].id !== 'HBuilder') {//js 170630js修改 调试模式下 会有 HBuilder的id
if(all[i].id == 'setting.html' || all[i].id == 'setting') {
console.log('逐个关闭页面(保留):setting.html '); //打印出了setting;
} else {
console.log('逐个关闭页面:' + all[i].id); //打印出了setting;
//all[i].close(); //这里关闭的逻辑最好放在又登录页跳转到主页时。若在主页close(),可能导致mui.back=function(){ //TODO } 不能生效
}
}
}

webview对象属性:(由 plus.webview.getWebviewById()获得)
{"__view_array__":[],"__IDENTITY__":"NWindow","__uuid__":"NWindow71491794985672","__callbacks__":{},"__callback_id__":"plus81491794985672","id":"setting","preload":true}

正文到此结束
本文目录