我遇到了错误 “TypeError:将循环结构转换为 JSON” 在使用 vuex-persistedstate 插件时。
import createPersistedState from 'vuex-persistedstate'
const store = new Vuex.Store({
// ...
plugins: [createPersistedState()]
})
我找到了一些使用插件的解决方案,没有错误,如下所示
plugins: [createPersistedState]
但它不保存状态详细信息。
最佳答案
您没有提到要将数据存储在何处。由于我将 vuex 数据存储在 localStorage 中,因此我的代码如下所示:
import createPersistedState from 'vuex-persistedstate'
const store = new Vuex.Store({
// ...
plugins: [createPersistedState(
storage: window.localStorage
)]
})
基本上,只需将 storage: window.localStorage 传递给您的 createPersistedState() 方法即可。
尽情享受吧!
关于vue.js - 类型错误 : Converting circular structure to JSON Vuejs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55529722/