A主页显示正常!我打印webview共四个 main父页面 子页面A(主页) B C 也对没问题。实在找不到哪里出问题了?
/**
* 创建iframe
* @param {Object} el
* @param {Object} opt
*/
var createIframe = function(el, opt) {
var elContainer = document.querySelector(el);
var wrapper = document.querySelector(".mui-iframe-wrapper");
if(!wrapper) {
// 创建wrapper 和 iframe
wrapper = document.createElement('div');
wrapper.className = 'mui-iframe-wrapper';
for(var i in opt.style) {
wrapper.style[i] = opt.style[i];
}
var iframe = document.createElement('iframe');
iframe.src = opt.url;
iframe.id = opt.id || opt.url;
iframe.name = opt.id;
wrapper.appendChild(iframe);
elContainer.appendChild(wrapper);
} else {
var iframe = wrapper.querySelector('iframe');
iframe.src = opt.url;
iframe.id = opt.id || opt.url;
iframe.name = iframe.id;
}
}
var app = new Vue({
el: '#app',
data: {
initIndex: 0, //[初始化参数]
title: '首页',
activeTab: 'index/index.html',
tabbar: [{
icon: 'icon-shouye',
title: '首页',
url: 'index/index.html'
},
{
icon: 'icon-dingdan',
title: '订单',
url: 'order/order_list.html'
},
{
icon: 'icon-wode1',
title: '我的',
url: 'personal/personal.html'
}
],
subStyle: {
top: '0px',
bottom: '51px'
}
},
mounted: function() {
mui.init();
// Vue实例化对象
var self = this;
// 初始化
if(mui.os.plus) {
mui.plusReady(function() {
var curWs = plus.webview.currentWebview();
console.log(self.tabbar.length);
for(var i = 0; i < self.tabbar.length; i++) {
var subUrl = self.tabbar[i].url;
var subWs = plus.webview.create(subUrl, subUrl, self.subStyle);
if(i != self.initIndex) {
subWs.hide();
}
curWs.append(subWs);
}
})
} else {
createIframe('.mui-content', {
url: self.tabbar[self.initIndex].url,
style: self.subStyle
})
}
},
methods: {
tab: function(index) {
var targetTab = this.tabbar[index].url;
//this.title = this.tabbar[index].title;
if(mui.os.plus) {
// 显示目标webview
if(targetTab == this.activeTab) {
return;
}
if(targetTab != 'index/index.html') {
mui.fire(plus.webview.getWebviewById(targetTab), 'loadData');
}
plus.webview.show(targetTab);
// 隐藏当前webview
plus.webview.hide(this.activeTab);
// 更改当前活跃的选项卡
this.activeTab = targetTab;
//plus.nativeUI.closeWaiting();
// 获取所有Webview窗口
var wvs = plus.webview.all();
for(var i = 0; i < wvs.length; i++) {
console.log('webview' + i + ': ' + wvs[i].getURL());
}
} else {
// 创建iframe代替子页面
createIframe('.mui-content', {
url: targetTab,
style: this.subStyle
})
}
}
}
})
0 个回复