vue fontawesome

使用步骤

1.安装

npm i --save @fortawesome/fontawesome-svg-core

Using Vue 2.x

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

Using Vue 3.x

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

2.安装 svg-icons

npm i --save @fortawesome/free-regular-svg-icons
npm i --save @fortawesome/free-solid-svg-icons

3.main.js

import Vue from 'vue'
import App from './App'
+ import { library } from '@fortawesome/fontawesome-svg-core'
+ import { faUserSecret } from '@fortawesome/free-solid-svg-icons'
+ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'

+ library.add(faUserSecret)
+ Vue.component('font-awesome-icon', FontAwesomeIcon)

Vue.config.productionTip = false

new Vue({
  el: '#app',
  components: { App },
  template: '<App/>'
})

App.vue

<template>
  <div id="app">
    <font-awesome-icon icon="user-secret" />
  </div>
</template>

参考资料

posted @ 2021-04-23 13:50  guangzan  阅读(380)  评论(0编辑  收藏  举报