admin 管理员组文章数量: 1086019
Angular项目开发,在定义一个TypeScript类的时候VSCode报错,提示为:
Property 'name' has no initializer and is not definitely assigned in the constructor
说是属性没有在构造器里面初始化。但是每个类每个属性都要初始化的话太麻烦了。
TypeScript官方文档中查到了方法,可以关闭这个检查:
https://www.typescriptlang/docs/handbook/release-notes/typescript-2-7.html
方法:tsconfig.json > compilerOptions, 增加一项:"strictPropertyInitialization":false, 这样就能不去做属性初始化了:
问题解决。
本文标签: 报错 ts Angular property constructor
版权声明:本文标题:Angular TS类报错:Property ‘name‘ has no initializer and is not definitely assigned in the constructor 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/b/1738255718a1951739.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论