我正在尝试将来自不同来源的所有图标导入为Icons
,类似于:
import * as Icons from {"@fortawesome/fontawesome-free-solid","@fortawesome/fontawesome-free-regular","@fortawesome/fontawesome-free-brands"}
但它的语法不正确。
答案 0 :(得分:3)
创建聚合器文件,即icons.js
import like from 'likeIcon.js';
import menu from 'menuIcon.js';
import bird from 'birdIcon.js';
export default {
like,
menu,
bird
};
然后您可以导入所需的所有图标
import {like, bird} from './icons.js';
您还可以导入图标对象
import icons from './icons.js'
然后将其用作icons.like
或icons.menu