【发布时间】:2019-10-14 07:28:21
【问题描述】:
我的create-react-app 项目中有一个图像文件夹,其中包含一堆图像。我想显示组件中的每一个图像。
├── Components
│ ├── Icons
│ │ ├── Icon.jsx (I want to display every single icon)
│
│
├── Images
│ ├── Icons
│ │ ├── ... (over 100 SVG icons)
在我的 .jsx 文件中,我想遍历每个图像/图标并显示它。
图标.jsx
import React, { Component } from 'react';
import Icons from '../../Images/Icons';
class Icons extends Component {
render() {
return (
//Loop over every icon and display it
);
}
}
【问题讨论】:
-
图像是否以特定顺序命名或具有与之关联的模式?
-
@Richard 到目前为止你尝试过什么?
-
@SatejS 是的,他们有特定的模式。它们具有命名约定,例如“轮廓”、“尺寸”等
-
假设有一些非常严格的命名约定和格式,例如“outline-250”、“outline-300”、“sizes-200”,您的渲染循环可能会随着数字。
标签: javascript reactjs loops jsx