mui子页面调用父页面的自定义方法

目前在开发APP的时候,有这样的一个需求:需要在登录页面返回后能够刷新父页面。

功能是这样的:在 A.html页面有头像和用户昵称,这些信息需要用户进行登录才能够拿到,登录页面是在B.html,点击A.html页面,跳转到B.html进行登录,在B.html登录成功后返回,返回的时候需要更新A.html的头像和用户昵称。

方法:在B.html页面点击返回的时候,触发A.html页面的自定义方法来实现。

具体看代码:项目是用VUE来做的,所以...

B.html :添加 beforeback方法:

mounted: function(){
    mui.init({
        beforeback:function(){
            var list = plus.webview.getWebviewById('music-index.html');
            mui.fire(list,'refresh');
            return true;
        },
    });
},

A.html 做接受这个方法,当然这个fire还可以进行传递参数

mounted: function() {        
    window.addEventListener('refresh',()=>{
        console.log('refresh fun');
        this.initialize(); // 具体方法
    });        
},

猜你喜欢

转载自www.cnblogs.com/e0yu/p/10319138.html
今日推荐