【发布时间】:2019-12-11 14:52:22
【问题描述】:
我正在尝试对 Vue 插件进行故障排除,以使其与 Nuxt 一起使用。它使用动态存储模块,并且由于某种原因,它使用的所有突变都会出现state is undefined 错误。
它的基本原理是:
index.js
import mixin from './src/mixin'
import store from './src/store'
export default {
install: function(Vue, options = {}) {
options = {
store: null,
...options
}
options.store.registerModule('shopify', store)
// define mixin
Vue.mixin(mixin)
}
}
然后store.js文件基本上是这样的:
export default {
state: {
product: [],
},
mutations: {
UPDATE_CACHED_RESULT(state, { id, data }) {
// This is the line that throws a state error
state.product[id] = data
}
},
actions: {
}
}
我假设我现在在 Nuxt 设置中的语法错误,但我正在画一个空白。
有什么帮助吗?
谢谢!
【问题讨论】: