Vue axios中this的指向问题

在Vue中this始终指向Vue,但axios中this为undefined,例如

 

若需要赋值给变量用以渲染数据,可以通过=>函数,这时this为Vue

 

或者可以直接通过:
let that = this
将this保存在that中,再在函数中使用that均可
被坑了很久,一直打印出来undefined,终于解决了!

原文地址:https://www.cnblogs.com/laogao123/p/9964826.html