1.箭头函数 (resp) => {//函数体} 或者 function (res) {}.bind(this)
axios.post('/app/user/loginSubmit',data) .then(function(res){ if(res.data){ this.error = ''; window.location.href = '/'; }else { this.error = '帐号或者密码错误'; } //console.log(res); }.bind(this)) .catch(function(err){ //console.log(err); }); axios.post('/app/user/loginSubmit',data) .then((res)=>{ if(res.data){ this.error = ''; window.location.href = '/'; }else { this.error = '帐号或者密码错误'; }