Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 导入大量图标_Javascript_Reactjs - Fatal编程技术网

Javascript 导入大量图标

Javascript 导入大量图标,javascript,reactjs,Javascript,Reactjs,我正在尝试通过AccuWeather API构建一个天气应用程序。每种天气类型都有图标,例如: 风,雨,云,和列表继续我在一个文件夹中总共有44个不同的图标图像 有没有一种方法可以更有序地导入它们?目前,我以以下方式手动导入它们: 从“../Weather icons/01-s.png”导入N1; 从“../Weather icons/02-s.png”导入N2; 从“../Weather icons/03-s.png”导入N3; 从“../Weather icons/04-s.png”导入N

我正在尝试通过AccuWeather API构建一个天气应用程序。每种天气类型都有图标,例如:

风,雨,云,和列表继续我在一个文件夹中总共有44个不同的图标图像 有没有一种方法可以更有序地导入它们?目前,我以以下方式手动导入它们:

从“../Weather icons/01-s.png”导入N1;
从“../Weather icons/02-s.png”导入N2;
从“../Weather icons/03-s.png”导入N3;
从“../Weather icons/04-s.png”导入N4;
从“../Weather icons/05-s.png”导入N5;
从“../Weather icons/06-s.png”导入N6;
从“../Weather icons/07-s.png”导入N7;
从“../Weather icons/08-s.png”导入N8;
从“../Weather icons/11-s.png”导入N11;
从“../Weather icons/12-s.png”导入N12;
从“../Weather icons/13-s.png”导入N13;
从“../Weather icons/14-s.png”导入N14;
从“../Weather icons/15-s.png”导入N15;
从“../Weather icons/16-s.png”导入N16;
从“../Weather icons/17-s.png”导入N17;
从“../Weather icons/18-s.png”导入N18;
从“../Weather icons/19-s.png”导入N19;
从“../Weather icons/20-s.png”导入N20;
从“../Weather icons/21-s.png”导入N21;
从“../Weather icons/22-s.png”导入N22;
从“../Weather icons/24-s.png”导入N24;
从“../Weather icons/25-s.png”导入N25;
从“../Weather icons/26-s.png”导入N26;
从“../Weather icons/29-s.png”导入N29;
从“../Weather icons/30-s.png”导入N30;
从“../Weather icons/31-s.png”导入N31;
从“../Weather icons/32-s.png”导入N32;
从“../Weather icons/33-s.png”导入N33;
从“../Weather icons/34-s.png”导入N34;
从“../Weather icons/35-s.png”导入N35;
从“../Weather icons/36-s.png”导入N36;
从“../Weather icons/37-s.png”导入N37;
从“../Weather icons/38-s.png”导入N38;
从“../Weather icons/39-s.png”导入N39;
从“../Weather icons/40-s.png”导入N40;
从“../Weather icons/41-s.png”导入N41;
从“../Weather icons/42-s.png”导入N42;
从“../Weather icons/43-s.png”导入N43;
从“../Weather icons/44-s.png”导入N44

不是以静态方式

如果您使用的是Webpack,那么您可以使用它来创建需求的动态映射,但在本例中,我不想为它操心,因为获取这些模块要困难得多,而且不再是静态分析的

不过,如果您愿意,您可以编写一个程序,通过列出目录的内容并写出
import
s来为您创建该文件