1.安装
`` `powershell
npm i --save @fortawesome/fontawesome-svg-core
Using Vue 2.x
```powershell
$ npm i --save @fortawesome/vue-fontawesome@latest
Using Vue 3.x
npm i --save @fortawesome/vue-fontawesome@prerelease
- 安装 svg-icons
npm i --save @fortawesome/free-regular-svg-icons
npm i --save @fortawesome/free-solid-svg-icons
- 引入icon
import { library } from '@fortawesome/fontawesome-svg-core'
// 引入所有图标
import * as faIcons from '@fortawesome/free-solid-svg-icons'
// 引入FontAwesomeIcon组件
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
Vue.component('font-awesome-icon', FontAwesomeIcon)
let iconMap = new Map()
// 这里由于图标有重复的,直接全部引入会报错
for (let [key, value] of Object.entries(faIcons)) {
if (!iconMap.get(value.iconName))
library.add(value)
iconMap.set(value.iconName, value)
}
原文链接: https://www.cnblogs.com/guangzan/p/14693444.html
标签:npm,--,svg,Fontawesome,fortawesome,vue2,fontawesome,引入,save From: https://www.cnblogs.com/-LemonWater-/p/17043505.html