我正在创建一个应用程序,但是,我希望当我单击Signup时,register()执行并返回一个我希望路由到登录路径的promise。
我没有留在同一个注册页面,而是想要路由到登录页面
register(){
axios.post('url', {
username: this.username,
password:this.password
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
答案 0 :(得分:2)
在路由器上使用push()
。
.then(function (response) {
console.log(response);
this.$router.push('login');
})
Vue-router有programmatic navigation。