[Vue warn]: Error in created hook: "TypeError: Cannot read properties of undefined (reading 'some')"
时间: 2023-10-14 12:04:21 浏览: 57
这个错误提示是在Vue的created钩子函数中出现了一个类型错误,具体是尝试读取一个未定义对象的属性'some'时出现了问题。根据引用中的提示,这个错误可能与'$emit'方法的调用有关,因为它也是尝试读取一个未定义对象的属性。在引用中提到的解决方式中,我们可以看到使用了一个eventBus来进行组件间通信的方法。在main.js中加入代码Vue.prototype.$bus = new Vue(),可以创建一个全局的eventBus实例,这样不同组件之间就可以通过这个eventBus进行通信。所以,你可以尝试在created钩子函数中使用this.$bus.$emit()来替代错误的调用,以解决这个问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [[Vue warn]: Error in created hook: “TypeError: Cannot read properties of undefined (reading ‘$on...](https://blog.csdn.net/Youweretrouble/article/details/129189556)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [[Vue warn]: Error in mounted hook: “TypeError: Cannot read properties of undefined (reading ‘$on...](https://blog.csdn.net/qq_45803094/article/details/126476879)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)