1.多加一层判断
let animal =cat || null
if(animal){}
2.断言方式(animal as Cat)
3. ?.
4.报错类型设为any
解决typescript 提示 Object is possibly ‘null‘
最新推荐文章于 2023-11-07 14:59:56 发布
1.多加一层判断
let animal =cat || null
if(animal){}
2.断言方式(animal as Cat)
3. ?.
4.报错类型设为any