vue3在方法中使用$store is not defined
时间: 2024-01-08 17:04:38 浏览: 116
回答: 当在Vue3中的方法中使用$store报错"$store is not defined"时,可能是因为在store/index.js中引入Vue和Vuex时,首字母大写了。在Vue3中,需要将引入的Vue和Vuex的首字母改为小写。例如,正确的引入方式应该是import Vue from 'vue'和import Vuex from 'vuex'。\[1\]这样修改后,再次尝试使用$store应该就不会报错了。
#### 引用[.reference_title]
- *1* [使用vuex 报错Property or method “$store“ is not defined](https://blog.csdn.net/honeycandys/article/details/118197725)[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^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* *3* [vuex中$store is not defined](https://blog.csdn.net/jinyuyang78/article/details/103363589)[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^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文