Rya*_*ton 5 javascript firebase vue.js vuex nuxt.js
我正在构建一个登录/注册系统作为应用程序的一部分。我正在使用 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))
}
}
Run Code Online (Sandbox Code Playgroud)
我在 Vue JS 2.6.10 上使用 Nuxt JS 2.9.2
我有几个模块。
我试过使用this.router.push('/')and window.location.href,但想保留 SPA 功能。
Vla*_*nko 10
你有两种方法可以做到:
$nuxt.$router.push 在行动中this.$router.push在您的操作中作为参数传递,并在您需要的地方调用。希望这可以帮助。
| 归档时间: |
|
| 查看次数: |
2752 次 |
| 最近记录: |