Received NaN for the `children`
2023-03-29 本文已影响0人
Jesse_001
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>
这样就可以了。