列表页使用了预加载打开详情页,详情用的viewgroup切换页面,列表页打开详情页后返回列表,再次点击列表进入详情页,使用mui.fire()传递的参数如何传递到viewgroup的子页面?现在是参数获取不到,常用操作方式。
列表页代码:
//添加列表项的点击事件
mui('#goods_list').on('tap', 'a', function(e)
{
var good_id = this.getAttribute("data-url");
//触发详情页面的newsId事件
mui.fire(detailPage,'get_good_id',{good_id:good_id});
//打开详情页面
mui.openWindow({
id : 'goodinfomain'
});
});
详情页代码:
<script>
mui.init();
var good_id = 0;
window.addEventListener('get_good_id', function(event)
{
//获得事件参数
good_id = event.detail.good_id;
plus.nativeUI.toast(good_id);
});
mui.plusReady(function()
{
//根据good_id向服务器请求商品详情
var group = new webviewGroup(plus.webview.currentWebview().id, {
items: [{
id: "goodinfobuy.html",
url: "./goodinfobuy.html",
styles:{
top:'45px',
bottom:'50px'
},
extras: {good_id: good_id}
}, {
id: "goodinfodetail.html",
url: "./goodinfodetail.html",
styles:{
top:'45px',
bottom:'50px'
},
extras: {good_id: good_id}
}, {
id: "goodinfoappraise.html",
url: "./goodinfoappraise.html",
styles:{
top:'45px',
bottom:'50px'
},
extras: {good_id: good_id}
}],
onChange: function(obj)
{
var c = document.querySelector(".header-tab-item .header-tab-selected");
if(c)
{
c.classList.remove("header-tab-selected");
}
var child_index = (parseInt(obj.index) + 1);
document.querySelector("#header-tabs li:nth-child("+child_index+") p").classList.add("header-tab-selected");
}
});
mui(".info-header-title").on("tap", "p", function(e)
{
var wid = this.getAttribute("data-wid");
group.switchTab(wid);
});
});