移动端app,mui页面交互之自定义侦听事件

b.html代码

//参数1:处罚这个事件的页面对象
//参数2:自定义事件名称,自取
//参数3:传值 Object 对象的形式
var homePage = plus.webview.currentWebview().opener();//获取a页面对象
var a = 1;
mui.fire(homePage, "xxxx",{id:a});

a.html

//a页面添加侦听自定义好的事件,当b页面执行到mui.fire(homePage, "xxxx",{id:a})这行代码时触发
window.addEventListener("xxxx", function (e) {
    //e是传过来的对象
    var id = e.detail.id //b传过来的1

    //other code

}

猜你喜欢

转载自blog.csdn.net/supertree_l/article/details/81531448