1、安装fontawesome
npm i nuxt-fontawesome -S
npm i @fortawesome/free-brands-svg-icons -S
npm i @fortawesome/free-regular-svg-icons -S
npm i @fortawesome/free-solid-svg-icons -S
2、配置
- 在plugins目录下创建
font-awesome.js
import Vue from 'vue'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
Vue.component('font-awesome-icon', FontAwesomeIcon)
Vue.config.productionTip = false
- 在nuxt.config.js添加配置
plugins: [
'~/plugins/font-awesome.js'
],
modules: [
'nuxt-fontawesome'
],
fontawesome: {
imports: [
{
set: '@fortawesome/free-solid-svg-icons',
icons: ['fas']
},
{
set: '@fortawesome/free-regular-svg-icons',
icons: ['far']
},
{
set: '@fortawesome/free-brands-svg-icons',
icons: ['fab']
}
]
},
3、使用
<font-awesome-icon :icon="['fas', 'search']"/>