1. 检查仓库模块是否遗漏:
namespaced: true // js
// vuex-class ts
// store/modules/channel
export const name = "channel"
export const namespaced = true
export const dynamic = true
2. store引用模块是否没有加入channel模块
// js
import Vue from 'vue';
import Vuex from 'vuex';
import channel './modules/channel'
Vue.use(Vuex);
export const store = new Vuex.Store({
modules: {
channel,
},
});
const createStore = () => {
return store
}
export default createStore
// ts
import Vue from 'vue';
import Vuex from 'vuex';
import * as channel './modules/channel'
Vue.use(Vuex);
export const store = new Vuex.Store({
modules: {
[channel.name]: channel,
},
});
const createStore = () => {
return store
}
export default createStore
3. 是否模块名称拼写错误
比如 modules
写成 moduels 或者 modles
const store = new Vuex.Store({
// modules拼写错误
modles: {
channel,
},
});
const store = new Vuex.Store({
// modules拼写错误
moduels: {
channel,
}
});
比如 channel
写成 chanel 或者 chennal 等
const store = new Vuex.Store({
modules: {
// channel拼写错误
chanel,
},
});
const store = new Vuex.Store({
modules: {
// channel拼写错误
chennal,
}
});