TypeError:将圆形结构转换为JSON Vuejs

时间:2019-04-05 06:51:25

标签: vue.js vuex

我遇到了错误  “ TypeError:将圆形结构转换为JSON ” 在使用vuex-persistedstate插件时。

import createPersistedState from 'vuex-persistedstate'

const store = new Vuex.Store({
  // ...
  plugins: [createPersistedState()]
})

我找到了一些使用插件的解决方案,如下所示,没有错误

plugins: [createPersistedState]

但是它不会保存状态详细信息。

1 个答案:

答案 0 :(得分:0)

您没有提到要在哪里存储数据。由于我将vuex数据存储在localStorage中,因此我的代码如下所示:

import createPersistedState from 'vuex-persistedstate'

const store = new Vuex.Store({
   // ...
   plugins: [createPersistedState(
     storage: window.localStorage
   )]
 })

因此,基本上,只需将 storage:window.localStorage 传递给您的 createPersistedState()方法。

享受!