z***@126.com
z***@126.com
  • 发布:2017-10-24 11:44
  • 更新:2017-10-24 13:59
  • 阅读:1058

如何在子页面的init()中接收父页面的传值?

分类:MUI

父页面是通过openWindow给子页面传值,父页面代码如下
mui.openWindow({
url:"banner-index.html",
id:"web/faxian/banner-index.html",
extras:{
bannerId:this.getAttribute("data-banner-id")
}
})

子页面只有init()方法,请问,子页面的init如何接收到父页面的传值?子页面代码如下:
mui.init({
subpages:[{
url:"banner.html",
id:"web/faxian/banner.html",
styles:{
top:"45px",
bottom:"45px"/
},
extras:{
data-banner-id: " 如何在这里接收到父页面的值????"
}
}]
});

2017-10-24 11:44 负责人:无 分享
已邀请:
n***@gmail.com

n***@gmail.com

你是要在父页面openWindow 子页面时传值,上半部分是对的,你想在子页面接收到值,在子页面中可以这样:

mui.plusReady(function() {  
     var self = plus.webview.currrentWebview()  
     console.log(self.bannerId)  
})

参考mui文档 openWindow的extras参数

  • z***@126.com (作者)

    但是我的子页面里的init初始化时还要再传值,这个值就是上个页面传过来继续往下传。所以遇到没法继续传的问题。

    2017-10-24 12:28

  • n***@gmail.com

    那你为什么不直接存到localStorage。。。

    2017-10-24 13:59

  • z***@126.com (作者)

    嗯,这也是我的备用方案,因为传参之前环境复杂,想直线解决,看来只能用它了。十分感谢。

    2017-10-24 14:11

uniapper

uniapper - abc

@DCloud_MUI_near
currentWebview 是函数。

mui.plusReady(function() {  
     var self = plus.webview.currrentWebview();  
     console.log(self.bannerId);  
})

该问题目前已经被锁定, 无法添加新回复