Open c3b2a7 opened 4 years ago
https://lolico.me/2020/04/22/Why-cannot-use-this-pointer-to-get-vue-instance/
不要在选项属性或回调上使用箭头函数,比如created: () => console.log(this.a)或vm.$watch('a', newValue => this.myMethod())。因为箭头函数并没有this,this会作为变量一直向上级词法作用域查找,直至找到为止,经常导致Uncaught TypeError: Cannot read property
https://lolico.me/2020/04/22/Why-cannot-use-this-pointer-to-get-vue-instance/
不要在选项属性或回调上使用箭头函数,比如created: () => console.log(this.a)或vm.$watch('a', newValue => this.myMethod())。因为箭头函数并没有this,this会作为变量一直向上级词法作用域查找,直至找到为止,经常导致Uncaught TypeError: Cannot read property