当前位置:网站首页>6-9 应用间通信 - 子应用通信

6-9 应用间通信 - 子应用通信

2022-06-22 10:43:00 bus_lupe

  1. 子应用1 - 父应用交互 - 子应用2
  2. customevent

应用2注册test1监听事件,并在回调函数中触发test2监听事件

window.customEvent.on('test1', () => {
    
  window.customEvent.emit('test2', {
    detail: 234})
})

应用1注册test1监听事件,触发test2监听事件

window.customEvent.on('test2', () => {
    
  // do something
})
window.customEvent.emit('test1')
原网站

版权声明
本文为[bus_lupe]所创,转载请带上原文链接,感谢
https://blog.csdn.net/bus_lupe/article/details/125343479