一直出现router使用不能识别,在axios中使用js路由我用的是function
axios.get('/user', {
params: {
ID: 12345
}
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
然后打印出this,出现undefined,没有this对象,将function改变箭头函数
axios.get('/user', {
params: {
ID: 12345
}
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.log(error);
});
this对象就出来了
.then((res) => {
//console.log(res.data);
if(res.data)
{
console.log(res.data)
Message({
showClose: true,
message: '登录成功!',
type: 'success'
});
this.$router.push('/HomePage')