不要在选项属性或回调上使用箭头函数

// 比如
created: () => console.log(this.a)
vm.$watch('a', newValue => this.myMethod())

因为箭头函数并没有 this,this会作为变量一直向上级词法作用域查找,直至找到为止

相关文章:

  • 2022-12-23
  • 2021-08-28
  • 2021-07-09
  • 2021-10-10
  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-04
  • 2021-12-24
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案