addEventListener和dispatchEvent
举个例子
//这里我们给全局添加了个名为CubeAppAutoSpeech.push的自定义事件
window.addEventListener('CubeAppAutoSpeech.push', (event) => {
console.log(event);
if(event.detail){
}
})
然后我们接下来去触发这个事件
window.dispatchEvent(new CustomEvent('CubeAppAutoSpeech.push', {
detail: {
//传参 定义事件的地方通过event.detail就可以获取到传故去的东西
}
}))