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