Received NaN for the children attribute. If this is expected, cast the value to a string
翻译成中文:收到children属性的nan。如果这是预期的,则强制执行
排查代码至这里,发现报错了
<div>{ data.province + data.city + data.region }</div>
因为react中的children属性是接受的是string类型,而不是NaN;由于第一次渲染的时候可能存在data为空对象的情况,导致上面的计算会变成undefined+undefined+undefined=NaN;
所以改成以下代码即可
<div>{ data.province ?? '' + data.city ?? '' + data.region ?? '' }</div>
同理在其他加减乘除的计算过程中导致的NaN也要进行兼容处理即可