飘过大山
飘过大山
  • 发布:2019-06-13 11:29
  • 更新:2019-09-11 11:57
  • 阅读:9114

最简单的uni-app返回携带参数解决方案

分类:uni-app

场景:A页面到B页面,B页面返回,A页面接收数据

A页面

//引入  
 import WxNotificationCenter  from '@/common/NotificationCenter.js'  

onLoad: function () {  
    //注册通知  
    WxNotificationCenter.addNotification('NotificationName', this.didNotification, this)  
  },  
    onUnload: function () {  
    //移除通知  
    WxNotificationCenter.removeNotification('NotificationName', this)  
  },  
methods:{  
   //通知处理  
  didNotification: function (info) {  
    var that = this  
    console.log(info)  
  },    
}

B页面

//引入  
 import WxNotificationCenter  from '@/common/NotificationCenter.js'  
 //发送通知  
 WxNotificationCenter.postNotificationName('NotificationName', '来自B页面')  

文件
http://e0c3afa5a2.hz22l-181.6464.cn/lian/NotificationCenter.js

3 关注 分享
4***@qq.com 4***@qq.com 1***@qq.com

要回复文章请先登录注册

秋天无风

秋天无风

下不了啦
2019-09-11 11:57
飘过大山

飘过大山 (作者)

回复 lioil :
加上去了,最后面
2019-06-28 10:26
lioil

lioil

NotificationCenter.js 没有看到哦。。
2019-06-28 10:24