在一些不是最新的浏览器中,我的 ReactJS 网站输出奇怪的 id,它们看起来像 immutableJS 对象的内部结构 这是在 IE10 中的渲染:
在 Chrome 和 Firefox 中,一切看起来都很好。 这是呈现第一个片段的代码:
const winner = this.props.worldviews.sort((a, b) => a.get('voteCount') < b.get('voteCount')).slice(0, 1).map(worldview => {
return (
<p>{worldview.get('title')}: {worldview.get('voteCount')} <i className='icon-check'></i></p>
);
});
this.props.worldviews
是 immutableJS 对象的列表。
我在这里做错了什么?
最佳答案
如果我调用.toArray()
,这个问题就可以解决在这样的 map 结果上:
const winner = this.props.worldviews.sort((a, b) => a.get('voteCount') < b.get('voteCount')).slice(0, 1).map(worldview => {
return (
<p>{worldview.get('title')}: {worldview.get('voteCount')} <i className='icon-check'></i></p>
);
}).toArray();
这应该不是问题,因为我使用的是 React 0.13,它支持任何迭代器,但显然在较旧的浏览器上它会崩溃。
关于javascript - React + immutableJS 在旧浏览器中呈现一些奇怪的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33344227/