vue配置font-awesome5

vue的配置就暫且不說,主要是以後的font-awesome5的配置:

一、安裝fontawesome基礎配置vue

npm i --save @fortawesome/fontawesome
npm i --save @fortawesome/vue-fontawesome

二、安裝fontawesome樣式依賴npm

npm i --save @forawesome/fontawesome-free-solid
npm i --save @forawesome/fontawesome-free-regular
npm i --save @fortawesome/fontawesome-free-brands

或者兩步合一svg

npm i --save @fortawesome/fontawesome @fortawesome/vue-fontawesome @forawesome/fontawesome-free-solid @forawesome/fontawesome-free-regular @fortawesome/fontawesome-free-brands

clipboard.png
三、在main.js中配置font-awesomespa

import fontawesome from '@fortawesome/fontawesome'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import solid from '@fortawesome/fontawesome-free-solid'
import regular from '@fortawesome/fontawesome-free-regular'
import brands from '@fortawesome/fontawesome-free-brands'
fontawesome.library.add(solid)
fontawesome.library.add(regular)
fontawesome.library.add(brands)
Vue.component('font-awesome-icon', FontAwesomeIcon)

clipboard.png
四、在vue頁面使用code

<font-awesome-icon :icon="['far','address-book']"/>
固然並不是必定要寫成font-awesome-icon標籤,它只是組件與main.js裏面的Vue.component對照,main.js的Vue.component只是將其做爲全局組件。在:icon="['樣式','省去樣式前綴的圖表名']",

clipboard.png
上面這些是使用font-awesome 5.0.13component


對於5.6.3版原本說,由於新增長了Font Awesome SVG Core.因此5.6.3的安裝:
一、安裝fontawesome基礎配置blog

npm i --save @fortawesome/fontawesome-svg-core
npm i --save @fortawesome/free-solid-svg-icons
npm i --save @fortawesome/vue-fontawesome

二、在main.js中配置font-awesomeip

import { library } from '@fortawesome/fontawesome-svg-core'
import { fas } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
library.add(fas)
Vue.component('font-awesome-icon', FontAwesomeIcon)

三、在頁面中能夠寫入it

<font-awesome-icon icon="address-book" />

class

<font-awesome-icon :icon="['fas', 'address-book']" />

對於非fas的能夠直接寫

<font-awesome-icon far icon="spinner" />

clipboard.png

還剩下fal和fab的這兩項在5.6.3版本中尚不知道不用pro該怎麼安裝,求大佬補充

相關文章
相關標籤/搜索