欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

VUEX采坑之路之獲取不到$store的解決方法

 更新時(shí)間:2019年11月08日 15:14:32   作者:竹春  
今天小編就為大家分享一篇VUEX采坑之路之獲取不到$store的解決方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧

今天在寫vuex的時(shí)候遇到了一個(gè)特別無語的問題,找了半個(gè)小時(shí)才找到這個(gè)問題,所以貼出來,大家在遇到和我一樣的問題的時(shí)候不會(huì)太過慌張

在第一次寫vuex的時(shí)候無論如何獲取不到$store,后來找了好久才發(fā)現(xiàn)是我給全局VUE注入的時(shí)候注入的是Store而非store

這一個(gè)字母之差看上去可能沒什么問題,可就是獲取不到全局的$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的解決方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論