Javascript 未捕获(承诺中)类型错误:无法读取属性';电子邮件';未定义的

Javascript 未捕获(承诺中)类型错误:无法读取属性';电子邮件';未定义的,javascript,vue.js,Javascript,Vue.js,我将vuejs应用程序与laravel一起使用,但我无法真正从对象中获取组件我该怎么做 <script> import axios from 'axios'; export default { data : function (){ return { email: '', password: '', remember: 'true', errors: [],

我将vuejs应用程序与laravel一起使用,但我无法真正从对象中获取组件我该怎么做

<script>
import axios from 'axios';
export default {
    data : function (){
        return {
            email: '',
            password: '',
            remember: 'true',
            errors: [],
        }
    },
    methods : {
        validateemail(mail){
            var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
            return re.test(mail);
        },
        attemptlogin(){
            this.errorsarray = [];
            axios.post('/login', {
                email: this.email,
                password: this.password,
                remember : this.remember
            }).then(function (response) {
                    location.reload();
                }).catch(function (error) {
                var code = error.response.status;
                console.log(this.email);
                    if(code == 422){


                        this.errors.push("Incorrect information");

                    }else{
                        console.log('no');
                        this.errors.push('Internal server error please try again later')
                    }
                }).then(function () {
                console.log('here');
            });
        },
    },
    computed : {
        isValidInput() {

            return this.validateemail(this.email) && this.password;
        }
    }
}

从“axios”导入axios;
导出默认值{
数据:函数(){
返回{
电子邮件:“”,
密码:“”,
记住:“真的”,
错误:[],
}
},
方法:{
validateemail(邮件){
变量re=/^([^()\[\]\\,;:\s@“]+(\.[^()\[\]\,;:\s@“]+)*)(“+”)(\[[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[1,3}.[0-9]{1,3}.]124;([a-zA Z-0-9]+];
返回重新测试(邮件);
},
attemptlogin(){
this.errorsarray=[];
axios.post(“/login”{
电子邮件:this.email,
密码:this.password,
记住:这个
}).然后(功能(响应){
location.reload();
}).catch(函数(错误){
var代码=error.response.status;
console.log(this.email);
如果(代码==422){
此.errors.push(“错误信息”);
}否则{
console.log('no');
this.errors.push('内部服务器错误,请稍后再试')
}
}).然后(函数(){
console.log('here');
});
},
},
计算:{
isValidInput(){
返回this.validateemail(this.email)和&this.password;
}
}
}

它也会显示这种错误

未捕获(承诺中)TypeError:无法读取未定义的属性“email”

我不知道为什么要帮忙? 提前感谢

使用
()=>{}
函数语法而不是
function(){}
。前者将正确绑定此

.catch(错误=>{
console.log(this.email);
})
如果要使用
函数(){}
,则必须显式绑定

.catch(函数(错误){
console.log(this.email);
}.绑定(本)
有关
bind
的更多信息,请参阅