Vue 3 全局使用 FontAwesome 图标库
安装图标库
npm i --save @fortawesome/vue-fontawesome@prerelease npm i --save @fortawesome/fontawesome-svg-core npm i --save @fortawesome/free-solid-svg-icons
使用图标库:
显示图标的时候主题名字没有前缀 fa
// 全局使用 import { library } from "@fortawesome/fontawesome-svg-core"; import { faPhone } from "@fortawesome/free-solid-svg-icons"; library.add(faPhone); import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; createApp(App).component("font-awesome-icon", FontAwesomeIcon) .mount("#app"); // 显示图标 // <FontAwesomeIcon icon="phone" /> // <FontAwesomeIcon icon="heart" /> // <FontAwesomeIcon icon="home" />