- props
- 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