不要在选项属性或回调上使用箭头函数
// 比如 created: () => console.log(this.a) vm.$watch('a', newValue => this.myMethod())
因为箭头函数并没有 this,this会作为变量一直向上级词法作用域查找,直至找到为止
不要在选项属性或回调上使用箭头函数
// 比如 created: () => console.log(this.a) vm.$watch('a', newValue => this.myMethod())
因为箭头函数并没有 this,this会作为变量一直向上级词法作用域查找,直至找到为止
转载于:https://www.cnblogs.com/223zzm/p/11266714.html