1.不应该使用箭头函数来定义一个生命周期方法
2.不应该使用箭头函数来定义 method 函数
3.不应该使用箭头函数来定义计算属性函数
4.不应该对 data 属性使用箭头函数
5.不应该使用箭头函数来定义 watcher 函数

原因:
箭头函数绑定了父级作用域的上下文,this 将不会按照期望指向 Vue 实例。
也就是说,你不能使用this来访问你组件中的data数据以及method方法了。
this将会指向undefined。经常导致 Uncaught TypeError: Cannot read property of undefined 或 Uncaught TypeError: this.myMethod is not a function 之类的错误

相关文章:

  • 2022-01-31
  • 2022-12-23
  • 2021-09-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
猜你喜欢
  • 2021-04-29
  • 2021-11-06
  • 2022-12-23
  • 2021-12-24
  • 2022-12-23
  • 2021-11-27
  • 2021-04-05
相关资源
相似解决方案