MUI-返回上一页带值(自定义事件)
A页面:
//添加自定义事件监听
window.addEventListener('CustomEvent', function(event) {
//获得事件参数 不可少.detail.
var isNeedUpdate = event.detail.isNeedUpdate;
var menuId = event.detail.menuId;
var unreadChangeCount = event.detail.unreadChangeCount;
console.log("isNeedUpdate=" + isNeedUpdate);
console.log("menuId=" + menuId);
console.log("unreadChangeCount(可为±值)=" + unreadChangeCount);
//TODO
//获取到带回来的值,根据业务需求做处理
});
B页面:
mui.init({
beforeback: function() {
//获得列表界面的webview
var main = plus.webview.getWebviewById('main.html');//不设置默认为url
if(mui != null)
mui.fire(main, 'CustomEvent', {
isNeedUpdate: true,
menuId: 1002,
unreadChangeCount: -1
});
//TODO
//返回true,继续页面关闭逻辑
return true;
}
});
正文到此结束