美文网首页
Received NaN for the `children`

Received NaN for the `children`

作者: Jesse_001 | 来源:发表于2023-03-29 14:17 被阅读0次

    React项目做完发现浏览器控制台报错:
    Received NaN for the 'children' attribute. If this is expected, cast the value to a string
    出现这种报错原因是:页面内有数学计算,计算结果需转为String类型。我的页面中有几处以下代码:

    <span>{info.total - info.done}%</span>
    

    修改为:

    <span>{(info.total - info.done).toString()}%</span>
    

    这样就可以了。

    相关文章

      网友评论

          本文标题:Received NaN for the `children`

          本文链接:https://www.haomeiwen.com/subject/fgyfddtx.html