반응형
Nuxt JS vuex에서 Vue 라우터를 사용하여 리디렉션
앱의 일부로 로그인/등록 시스템을 구축하고 있습니다.Firebase와 Vuex를 사용하여 인증 및 데이터베이스 정보를 처리하고 있습니다.Nuxt JS에는 사용자를 생성하고 로그인하고 로그아웃하는 작업이 있습니다.
사용자가 성공적으로 등록된 후/로그인을 클릭하면 내 코드가 다음과 같습니다.
export const actions = {
/*
* Create a user
*/
createUser ({commit}, payload) {
this.$fireAuth.createUserWithEmailAndPassword(payload.email, payload.password).then(function(firebaseUser) {
commit('setUser', payload)
}).catch(function(error) {
console.log('error logging in' + error)
});
},
/*
* Log a user into Beacon
*/
login ({commit}, payload) {
this.$fireAuth.signInWithEmailAndPassword(payload.email, payload.password).then(function(firebaseUser) {
commit('setUser', payload)
}).catch(function(error) {
console.log('error logging in' + error)
});
},
/*
* Sign a user out of Beacon
*/
signOut ({commit}) {
this.$fireAuth.signOut().then(() => {
commit('setUser', null)
}).catch(err => console.log(error))
}
}
Vue JS 2.6.10에서 Nuxt JS 2.9.2를 사용하고 있습니다.
모듈이 몇 개 있습니다.
사용해보았습니다.this.router.push('/')
그리고.window.location.href
단, SPA 기능을 유지하고 싶습니다.
다음 두 가지 방법이 있습니다.
$nuxt.$router.push
행동 중에- 통과하다
this.$router.push
필요에 따라 전화를 걸 수 있습니다.
이게 도움이 됐으면 좋겠다.
언급URL : https://stackoverflow.com/questions/57857559/redirect-using-vue-router-in-nuxt-js-vuex
반응형
'sourcecode' 카테고리의 다른 글
Vuex 작업 페이로드가 정의되지 않았습니다. (0) | 2022.08.07 |
---|---|
jwt 인증을 사용하여 vue 응용 프로그램에 자동 로그인 (0) | 2022.08.07 |
LD_PRELOAD 메커니즘을 사용한 'malloc' 재정의 (0) | 2022.08.07 |
VueJs 및 Larabel을 사용하여 여러 파일 업로드 (0) | 2022.08.07 |
webpack,vue.dll,vue 파일을 컴파일할 수 없습니다. (0) | 2022.08.07 |