代码语言:javascript复制
const options = {
state() {
return {}
},
actions: {},
mutations: {},
modules: {
...
}
}
export const store = createStore({
...options,
plugins: [
...
]
})
// 重置store
export function resetStore() {
store.replaceState(createStore(options).state)
}
注: 不能直接store.replaceState({}),会导致所有数据结构和响应性丢失