在这里 react 新手。
我有一张标签图 ['a', 'b', 'c']
我有每个图像(a.jpg,b.jpg,c.jpg)
我如何包含/要求迭代并显示每个图像作为我的 map 的一部分?
感谢任何帮助:D
最佳答案
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')
);
关于image - React - map 中的动态图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45450278/