原文:typescript报错:Object is possibly 'null' 请问怎么解决?

这么写是不行的吗 请问应该怎么写呢 readonly state fold: true, answer: null render return this.state.answer amp amp this.state.answer.content 最佳答案 readonly state: any fold: true, answer: null 如果未能解决,请移步:ts报错:Object is ...

2020-12-05 13:05 0 1392 推荐指数:

查看详情

解决typescript:error TS2531: Object is possibly 'null'.问题

原因是什么呢?是ts编译器在编译时诊断到document.getElementById('test')可能会为null,所以给出了这样一个提示:对象可能为null解决方式是这样: 加一个!,感叹号什么意思呢,它其实是not null 的断言操作符,不执行运行时检查,告诉编译器只需要 ...

Sun Jan 02 04:57:00 CST 2022 0 1599
TS2532: Object is possibly 'undefined'.

报错代码: //定义请求拦截器 service.interceptors.request.use( (config) => { if (window.localStorage.Token && window.localStorage.Token.length ...

Tue Mar 22 00:50:00 CST 2022 0 1187
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM