vuejs 2路由器的奇怪错误
wierd bug with vuejs 2 router
这是我的 axios 请求的一部分:
.then(function (response) {
self.forms.process = false;
if( response.data.redirect ){
console.log(123);
router.push( { name: response.data.redirect } );
}
})
.catch(function (error) {
console.log(error.response.data);
如果我删除 router.push- 没有错误。
但是 router.go 我在 console.log(error.response.data) 行有一个错误:
- //这里是console.log在router.push
之前打印的123
- 未捕获(承诺)TypeError:无法读取未定义的 属性 'data'
我不明白如何修复该错误
我应该使用 self.$router.push 而不是 router.push
这是我的 axios 请求的一部分:
.then(function (response) {
self.forms.process = false;
if( response.data.redirect ){
console.log(123);
router.push( { name: response.data.redirect } );
}
})
.catch(function (error) {
console.log(error.response.data);
如果我删除 router.push- 没有错误。 但是 router.go 我在 console.log(error.response.data) 行有一个错误:
- //这里是console.log在router.push 之前打印的123
- 未捕获(承诺)TypeError:无法读取未定义的 属性 'data'
我不明白如何修复该错误
我应该使用 self.$router.push 而不是 router.push