VUEX采坑之路之获取不到$store的解决办法

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

VUEX采坑之路之获取不到$store的解决办法

  2021-04-02 我要评论

今天在写vuex的时候遇到了一个特别无语的问题,找了半个小时才找到这个问题,所以贴出来,大家在遇到和我一样的问题的时候不会太过慌张

在第一次写vuex的时候无论如何获取不到$store,后来找了好久才发现是我给全局VUE注入的时候注入的是Store而非store

这一个字母之差看上去可能没什么问题,可就是获取不到全局的$store;

代码奉上

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import font from './static/js/font.js';
import './static/scss/animate.css'
Vue.config.productionTip = false
import Store from './store/store.js';
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
Store,
components: { App },
template: '<App/>'
})

我之前就是这么写的,所以一直出不来,可是逻辑根本没有问题

之后我把大写的S换成了小写的s就出来了

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import font from './static/js/font.js';
import './static/scss/animate.css'
Vue.config.productionTip = false
import store from './store/store.js';
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
store,
components: { App },
template: '<App/>'
})

以上这篇VUEX采坑之路之获取不到$store的解决方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

您可能感兴趣的文章:

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们