| 
 | 
 
使用 
 
注册通知 
- // 最好在onLoad中进行
 
 - /**
 
 - * addNotification
 
 - * 注册通知对象方法
 
 - * 
 
 - * 参数:
 
 - * name: 注册名,一般let在公共类中
 
 - * selector: 对应的通知方法,接受到通知后进行的动作
 
 - * observer: 注册对象,指Page对象,可选,不填写的话在remove中会失效
 
 - */
 
  
- var that = this
 
 - WxNotificationCenter.addNotification("testNotificationName",that.testNotificationFn,that)
 
  复制代码 发送通知 
- WxNotificationCenter.postNotificationName("testNotificationName");
 
  复制代码 
 
移除通知 
- // 移除通知在本也完成
 
 - WxNotificationCenter.removeNotification("testTabNotificationName",that)
 
  复制代码 特性源码分析 
 
 
- <font style="color: rgb(64, 120, 192);">var __notices = [];</font>
 
  复制代码存放通知数组 
 addNotification 注册方法  
 - <font style="color: rgb(64, 120, 192);">* addNotification
 
 - * 注册通知对象方法
 
 - * 
 
 - * 参数:
 
 - * name: 注册名,一般let在公共类中
 
 - * selector: 对应的通知方法,接受到通知后进行的动作
 
 - * observer: 注册对象,指Page对象
 
 - */</font>
 
  复制代码 postNotificationName 发送方法 
 
- <font style="color: rgb(64, 120, 192);">/**
 
 - * postNotificationName
 
 - * 发送通知方法
 
 - * 
 
 - * 参数:
 
 - * name: 已经注册了的通知
 
 - * info: 携带的参数
 
 - */
 
  
- function postNotificationName(name, info)</font>
 
  复制代码 removeNotification 移除方法 
- <font style="color: rgb(64, 120, 192);">/**
 
 - * removeNotification
 
 - * 移除通知方法
 
 - * 
 
 - * 参数:
 
 - * name: 已经注册了的通知
 
 - * observer: 移除的通知所在的Page对象
 
 - */
 
  
- function removeNotification(name,observer)</font>
 
  复制代码 
 
 
 
 |  
  
 
 
 |   
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册 
 
 
 
×
 
 
 
 
 |