一个页面通过 mui.init 方法载入了 subpages:
mui.init({
swipeBack: false,
statusBarBackground: '#f7f7f7',
subpages: [{
id: 'main-list',
url: 'main-list.html',
styles: {
top: '48px',
bottom: 0,
bounce: 'vertical'
}
}]
});
现在我想给 main-list 发event。在plus.ready 方法中使用如下代码:
var mainListPage = plus.webview.getWebviewById("main-list");
console.log(mainListPage);
提示 mainListPage 是 undefined 。
请问怎么才能给 subpages 发送 event?
2 个回复
DCloud_UNI_FXY
应该是你获取的时候,还没有生成。
方案1:手动create该webview,然后append到当前webview,在发送事件。
方案2:延迟发送事件
YanRong (作者)
还是通过本地存储来实现页面传值了。
不过plus.storage 的效率太慢了,还是需要延迟才可以,所以使用了HTML5本来的localStorage.