ts报错Declaration of public instance field not allowed after declaration of public

ts出现报错Declaration of public instance field not allowed after declaration of public instance method. Instead, this should come at the beginning of the class/interface.的解决办法...

ts出现报错Declaration of public instance field not allowed after declaration of public instance method. Instead, this should come at the beginning of the class/interface.的解决办法


原因分析:声明变量之前插入了函数


解决方案:将变量申明提到最前边


错误写法:

attachments-2021-07-pzeP5VF860f985cdd3543.png


正确写法:

attachments-2021-07-KOxX6tXO60f985f341baa.png


总结:

在ts中变量一定要写在函数的上方才可以。

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
admin
admin

651 篇文章

作家榜 »

  1. admin 651 文章
  2. 粪斗 185 文章
  3. 王凯 92 文章
  4. 廖雪 78 文章
  5. 牟雪峰 12 文章
  6. 李沁雪 9 文章
  7. 全易 2 文章
  8. Stevengring 0 文章