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);
}

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