programing

nuxt Auth Module과 vuex-persist의 비교 가능성 문제가 있습니까?

bestcode 2022. 8. 15. 21:13
반응형

nuxt Auth Module과 vuex-persist의 비교 가능성 문제가 있습니까?

nuxt Auth 모듈과 vuex-persist와 호환되는 문제가 있습니까?

이렇게 vuex-persist를 추가했습니다.

// Inside - nuxt.config.js
export default {
  plugins: [
    { src: '~/plugins/vuex-persist', ssr: false }
  ]
}

// ~/plugins/vuex-persist.js
import VuexPersistence from 'vuex-persist'

export default ({ store }) => {
  window.onNuxtReady(() => {
    new VuexPersistence({
    /* your options */
    }).plugin(store);
  });
}

근데 안 되네.

  1. login(로그인)을 클릭하면 이전 작업(google로 로그인/기타 클릭)이 수행됩니다.
  2. 로그인하면 상태가 유지되지 않습니다.

이에 대한 해결책이 있나요?

네, 에 몇 가지 문제가 있었습니다.@nuxtjs/auth모듈 및vuex-persist,

이것을 사용하다

// ~/store/index.js
import VuexPersistence from 'vuex-persist'
const vuexLocal = new VuexPersistence({
  storage: window.localStorage
})

export const plugins = [vuexLocal.plugin]

문서에 기재되어 있는 것 대신에

// Inside - nuxt.config.js
export default {
  plugins: [
    { src: '~/plugins/vuex-persist', ssr: false }
  ]
}
// ~/plugins/vuex-persist.js
import VuexPersistence from 'vuex-persist'

export default ({ store }) => {
  window.onNuxtReady(() => {
    new VuexPersistence({
    /* your options */
    }).plugin(store);
  });
}

또는 vuex-displate를 대신 사용할 수 있습니다.

언급URL : https://stackoverflow.com/questions/60509730/is-the-any-comparability-issue-with-nuxt-auth-module-and-vuex-persist

반응형