我正在使用Webpack + Vue + vue-fontawesome。
下面的代码可以正常工作并显示图标。
import @fortawesome/free-solid-svg-icons
但是这个不显示图标。
import faCalendarCheck component in @fortawesome/free-regular-svg-icons
Similary,@fortawesome/free-regular-svg-icons
中的其他组件无效。
组件会呈现HTML <\!---->
的注释行。
为什么@ fortawesome / free-regular-svg-icons不起作用?
main.js
// Font Awesome
import { library } from '@fortawesome/fontawesome-svg-core';
import {
faThLarge,
// faCalendarCheck,
faBell,
faAddressBook,
faCalculator,
faSitemap,
faEnvelope,
faWindowMaximize,
faFileAlt,
faNewspaper,
} from '@fortawesome/free-solid-svg-icons';
import {
faCalendarCheck,
} from '@fortawesome/free-regular-svg-icons';
library.add(faThLarge);
library.add(faCalendarCheck);
library.add(faBell);
library.add(faAddressBook);
library.add(faCalculator);
library.add(faSitemap);
library.add(faEnvelope);
library.add(faWindowMaximize);
library.add(faFileAlt);
library.add(faNewspaper);
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
Vue.component('font-awesome-icon', FontAwesomeIcon);
app.vue
<template>
<font-awesome-icon icon="calendar-check" />
</template>
package.json
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.2",
"@fortawesome/free-brands-svg-icons": "^5.2.0",
"@fortawesome/free-regular-svg-icons": "^5.2.0",
"@fortawesome/free-solid-svg-icons": "^5.2.0",
"@fortawesome/vue-fontawesome": "^0.1.1"
}
答案 0 :(得分:2)