vue 自定義全局函數報錯undefined

報錯如下:
vue Uncaught (in promise) TypeError: Cannot read property ‘dealLogin’ of undefined

原因如下:
.then(function (response) { //這裏不允許this
this.dealLogin(response);
}

改爲如下解決問題:
.then((response) => { //yes,完美,解決啦!看一下有什麼不同
this.dealLogin(response);
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章