为什么调试器行未命中?请让我知道如何修改代码,以便使其成功。
async _store_token(tok){ // tried this line with and without 'async', just to see
debugger; // THIS LINE DOESN'T GET CAUGHT BY DEBUGGER
}
componentWillMount(){
//debugger;
axios({
method: 'post',
url: BASE_URL + '/users/login',
data: {
email: "email1@mail.com",
password: "passpass"
}
})
.then(async function (res) {
debugger; // CODE IS FINE AT THIS DEBUG STATEMENT
_store_token(res.token); // TRIED TO USE 'this._store_token(res.token);'
// but it didn't work either
})
答案 0 :(得分:0)
原因是scope
关键字中的this
。可能是您想使用箭头方法功能。
示例
then(async res => {})