programing

VueNuxtNextServerInit에서 데이터를 로드하지 않습니다.

easyjava 2023. 6. 13. 22:53
반응형

VueNuxtNextServerInit에서 데이터를 로드하지 않습니다.

Vuex Store에서 정의합니다.nuxtServerInit()전혀 초기화되지 않습니다!

import Vuex from 'vuex'
import mod1 from './modules/mod1'
import mod2 from './modules/mod2'

const store = () => {
    return new Vuex.Store({
        actions: {
            nuxtServerInit() {
                setTimeout(() => console.log('Hello'), 10000)   
            }
        },
        modules: {
           mod1,
           mod2
        }
    })
}

export default store

내가 뭘 잘못하고 있나요?도와주세요!

전화하는 것이 확실합니까?NuxtServerInit부터store/index.js그리고 당신은 모듈 모드에 있지 않습니까?

Vuex 저장소의 모듈 모드를 사용하는 경우 기본 모듈(store/index.js에 있음)만 이 작업을 수신합니다.여기서 모듈 작업을 연결해야 합니다.

https://nuxtjs.org/guide/vuex-store/

아래 예시와 같이 시도할 수 있습니다.

actions: {
  nuxtServerInit ({ commit }, { req }) {
    if (req.session.user) {
      commit('user', req.session.user)
    }
  }
}

자세한 내용은 여기를 참조하십시오.

언급URL : https://stackoverflow.com/questions/52468295/vue-nuxt-nuxtserverinit-doesnt-load-the-data

반응형