【发布时间】:2017-08-02 01:58:27
【问题描述】:
在这里反应新手。
我有一张标签图 ['a', 'b', 'c']
我有每个图像(a.jpg、b.jpg、c.jpg)
我将如何包含/要求迭代并将每个图像显示为我的地图的一部分?
任何帮助表示赞赏:D
【问题讨论】:
-
你的标签和地图有关系吗?例如'a' --> a.jpg, 'b' --> b.jpg
标签: image reactjs dictionary react-dom
在这里反应新手。
我有一张标签图 ['a', 'b', 'c']
我有每个图像(a.jpg、b.jpg、c.jpg)
我将如何包含/要求迭代并将每个图像显示为我的地图的一部分?
任何帮助表示赞赏:D
【问题讨论】:
标签: image reactjs dictionary react-dom
var Foo = React.createClass({
render: function() {
const images = ['a','b','c']
const imagesElements = images.map( e => {
return (
<img src={`${e}.jpg`} />
)
});
return(
<div>
{imagesElements}
</div>
)
}
});
ReactDOM.render(
<Foo name="bar" />,
document.getElementById('container')
);
【讨论】:
${e}.jpg} - 现在更有意义了。谢谢!