您好,打包装到 iPad 上去调试,A ->B 之后,第一次调用 webView.back 会显示白屏,页面切换使用的 webView.loadUrl ,代码如下:
var sub = plus.webview.create(_basePath + 'pages/canlucate/canlucate.html', 'subpage-web', {
left: '80px',
right: '0px',
top: '55px',
bottom: '0px',
popGesture: 'none',
scrollIndicator: 'none'
});
plus.webview.currentWebview().append(sub);
mui('.mui-bar ul').on('tap', 'li', function() {
var href = this.getAttribute('data-href');
if(sub.getURL() != href) {
sub.loadURL(_basePath + href);
} else {
sub.show();
}
switchMenu(href);
});
/**
* 注册页面切换事件
*/
window.addEventListener('loadUrl', function(e) {
var url = e.detail.url;
if(sub.getURL() != url) {
sub.loadURL(_basePath + url);
} else {
sub.show();
}
switchMenu(url);
});
/**
* 注册页面回退事件
*/
window.addEventListener('goBack', function(e) {
sub.canBack(function(e) {
if(e.canBack) {
sub.back();
switchMenu(sub.getURL());
}
});
});
这里是页面JS
//链接跳转
var mainWebView;
function goUrl(url,id,options){
if(url.startWith('http://') || url.startWith('https://')){
if(mui.os.plus){
plus.runtime.openURL(url);
}else{
mui.openWindow(url);
}
return;
}
if(url.indexOf('.html') == -1){ //不包含 .Html 后缀
if(url.lastIndexOf('?') != -1){//Url中包含有参数
url = url.substring(0,url.lastIndexOf('?')) + '.html'+url.substring(url.lastIndexOf('?'));
}else{ //Url 不包含参数
url += '.html';
}
}
if(!mainWebView){
mainWebView = plus.webview.currentWebview().parent();
}
mui.fire(mainWebView,'loadUrl',{url: url});
}
返回
/**
* 返回上一页
*/
function goBack(){
mui.back();
}
mui.back = function(){
if(!mainWebView){
mainWebView = plus.webview.currentWebview().parent();
}
mui.fire(mainWebView,'goBack');
}
附件是测试Demo,烦请看下,谢谢,测试流程 ,左侧导航栏 客户--》客户列表--》点击某一个客户--》点击左上角返回按钮