programing

nuxt vuex에서 정의되지 않은 커밋

bestcode 2022. 7. 13. 23:18
반응형

nuxt vuex에서 정의되지 않은 커밋

<script>
  computed: {
    loggedOut () {
      return this.$store.state.login.logged
    }
  },
  signin (store) {
      this.$auth.loginWith('local', {...code}
      }).then(this.$store.commit.login('login/LOGGED_IN')) // <- error in commit
    }
  }
}
</script>

logged Out() 계산 속성을 취득했는데 커밋하여 변환하려고 하면 다음 오류가 나타납니다.

[vuex] 알 수 없는 변환 유형: login/LOGGGED_입력

내 login.js 파일:

export const state = () => ({
  logged: false
})

export const mutations = () => ({
  LOGGED_IN (state) {
    state.logged = true
  },
  LOGGED_OUT (state) {
    state.logged = false
  }
})

index.disc 파일:

export const state = () => ({
})

export const mutations = {
}

일 때문이어야 한다

this.$store.commit('login/LOGGED_IN') 

Nuxt.js 기본 스토어/xxx.js(index.js를 제외한 각 .js 파일)는 1개의 모듈이기 때문에 모듈 방식을 사용하여 호출해야 합니다.

https://nuxtjs.org/guide/vuex-store#modules-mode 를 참조해 주세요.

당신의.login.js돌연변이 구문이 잘못되었습니다.nuxt.dism의 구문이 다릅니다.데모를 참조해 주세요.

export const mutations = {
  LOGGED_IN (state) {
    state.logged = true
  },
  LOGGED_OUT (state) {
    state.logged = false
  }
}

언급URL : https://stackoverflow.com/questions/61462810/commit-of-undefined-in-nuxt-vuex

반응형