import Vue from 'vue'; import Vuex from 'vuex'; Vue.use(Vuex); const store = new Vuex.store({ state:{ num:"我是vuex1" } }); export default store;
控制台顯示報錯
Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_1_vuex__.a.store is not a constructor
(是因為嘗試將不是構造器的對象或者變量來作為構造器使用。)
解決辦法:
將new Vuex.store中的“store”大寫
new vuex.Store
參考:
http://www.cnblogs.com/yufann/p/Vue-Node10.html