WxNotificationCenter icon indicating copy to clipboard operation
WxNotificationCenter copied to clipboard

Wepy框架使用通知时this会有问题

Open SamHz opened this issue 7 years ago • 1 comments

发现你的代码中使用了将page放在observer这样告成回调时this作用域会有问题,变成了{observer, selector, name}这样引用就不对了,而且没办法修改界面,所以我使改了你的代码 原来是这样 var newNotice ={ name: name, selector: selector, observer: observer }; 修改后: var newNotice = Object.assign(observer, {selector: selector}, {name: name}) /* { name: name, selector: selector, observer: observer };*/ 合并成一个对像才适用于Wepy

SamHz avatar Jun 27 '18 00:06 SamHz

wepy使用时候,this确实有问题,但是上边处理方法错误,Object.assign会让observer的监听只有一个,新添加监听会覆盖,正确做法是在原来代码上的postNotificationName方法里面的notice.selector(info);代码改为notice.selector.call(notice.observer, info);

xztl avatar Oct 13 '18 07:10 xztl