gpt4 book ai didi

vue.js - 类型错误 : Converting circular structure to JSON Vuejs

转载 作者:行者123 更新时间:2023-12-05 07:24:18 25 4
gpt4 key购买 nike

我遇到了错误 “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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com