6-6 Communication between applications-Father-child communication

  1. props
  2. customevent
    https://developer.mozilla.org/zh-CN/docs/Web/API/CustomEvent
export class Custom {
    
    
  // 事件监听
  on (name, cb) {
    
    
    window.addEventListener(name, (e) => {
    
    
      cb(e.detail)
    })
  }
  // 事件触发
  emit(name, data) {
    
    
    const event = new CustomEvent(name, {
    
    
      detail: data
    })
    window.dispatchEvent(event)
  }
}

Hollywood Principle - No need to contact me, I will call you when I need you
Dependency Injection - The display and hiding of the main application are injected into the sub-application, through the sub-application

Guess you like

Origin blog.csdn.net/bus_lupe/article/details/124136500