Property ‘$router‘ does not exist on type TS2339

诸葛明亮 2024-09-19 15:33:04 阅读 63

问题:Property 'XXX' does not exist on type '....

启动VUE项目的时候,VUE文件没有报错,但是npm run serve之后,项目报错。

参考网上的写法, 用this['router'] 可以解决此问题,没尝试过。

但是项目里太多地方使用this.写法,改起来太多了。

参考网友经验,在tsconfig.json 里面的compilerOptions下配置"noImplicitThis": false 可以解决Property '$router' does not exist on type 这种问题。

可以参考:前端 - Property '$router' does not exist on type - SegmentFault 思否



声明

本文内容仅代表作者观点,或转载于其他网站,本站不以此文作为商业用途
如有涉及侵权,请联系本站进行删除
转载本站原创文章,请注明来源及作者。