programing

TypeError: 원형 구조를 JSON Vuejs로 변환

prostudy 2022. 5. 24. 21:54
반응형

TypeError: 원형 구조를 JSON Vuejs로 변환

vuex-persistedstate 플러그인을 사용하는 동안 "TypeError: 순환 구조를 JSON으로 변환 중" 오류가 표시됨.

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.localStoragecreatePersistedState() 메서드에 전달하십시오.

즐겨라!

참조URL: https://stackoverflow.com/questions/55529722/typeerror-converting-circular-structure-to-json-vuejs

반응형