image - React - map 中的动态图像

标签 image reactjs dictionary react-dom

在这里 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')
);

https://jsfiddle.net/69z2wepo/83751/

关于image - React - map 中的动态图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45450278/

相关文章:

node.js - eslint-插件-导入 : for js files not svg or css

swift - 在 Swift 中对字典进行字符串化

html - 绘制 float 图像 HTML CSS

react-native - 图像未使用 API 的 map 方法显示( native react )

javascript - 在同级组件之间传递状态 React Router v4

css - 在 React Select 中使用 Tailwind Forms 插件

python - 计算字典中项目的频率

c# - 如何在全局范围内初始化全局嵌套字典?

ios - Xcode 6.1.1 为通用构建启动图像

html - 我可以包装 img alt 文本吗?