ts报错Property ‘zeroValue‘ has no initializer and is not definitely assigned in the constructor.

1.出现报错的几种原因

(1)属性类型不对

(2)没有初始化

(3)undefined或null

2.解决的方法

(1)tsconfig.json中修改

"compilerOptions": {
    "strictPropertyInitialization": false
  }

(2)非空断言!:

(3)?:

(5)联合 

value | undefined | null


版权声明:本文为zhangyr_student原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。