当前位置:   article > 正文

vue组件和index.html之间通讯_vue项目中index.html文件如何跟vue通信

vue项目中index.html文件如何跟vue通信

1:在main.js文件中加:

window.eventBus = new Vue();

2:在index.html中

window.eventBus.$emit("onHandler",JSON.parse(JSON.stringify(res)).data)

3:在vue组件

eventBus.$on('onHandler',(res)=>{//res})

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/588998
推荐阅读
相关标签
  

闽ICP备14008679号