a.js
notifyOthers() {
Window.post( new Event("app-wide-event") ); // 事件挂载 app-wide-event标识
}
["on click at button"]() {
this.notifyOthers();
}
b.js
const callback = () =>
this.componentUpdate {
counter: this.counter + 1
};
this.onGlobalEvent("app-wide-event", callback ); //监听全局事件 app-wide-event 标识
- 欢迎大家指导