首页 > 其他 > 详细

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

时间:2020-12-05 15:07:19      阅读:171      评论:0      收藏:0      [点我收藏+]

这么写是不行的吗?请问应该怎么写呢?

`

readonly state = {
    fold: true,
    answer: null
};

render () {
    return (
        
{ this.state.answer && this.state.answer.content }
) } `

 

最佳答案

 

readonly state: any = {
    fold: true,
    answer: null
};

如果未能解决,请移步:ts报错:Object is possibly ‘null‘ 详解

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

原文:https://www.cnblogs.com/8M0INF/p/14089173.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!