我在根组件中注入了store,然后在子组件中通过this.$store来访问store中的数据,然后我发现组件实例上根本不存在$store的属性,我在github上看vuex的demo,发现并没有区别。求助各位大神看看这到底是什么情况导致的~
main.js
import store from './store/store.js';
new Vue({
el:"#app",
router:router,
store, //这里已经注入到根组件中了啊?
render:h=>h(AppComponent)
})


Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
找到问题的原因了!!
我的导入方式是这样的
正确的导入方式应该这样