在Vue中this始終指向Vue,但axios中this爲undefined,例如
若需要賦值給變量用以渲染數據,可以通過=>函數,這時this爲Vue
或者可以直接通過:
let that = this
將this保存在that中,再在函數中使用that均可
被坑了很久,一直打印出來undefined,終於解決了
轉自:http://blog.csdn.net/qq_30378229/article/details/78429374
在Vue中this始終指向Vue,但axios中this爲undefined,例如
若需要賦值給變量用以渲染數據,可以通過=>函數,這時this爲Vue
或者可以直接通過:
let that = this
將this保存在that中,再在函數中使用that均可
被坑了很久,一直打印出來undefined,終於解決了
轉自:http://blog.csdn.net/qq_30378229/article/details/78429374