如何在 laravel 项目的 VueJS 上使用 Font Awesome 5

How to use Font Awesome 5 on VueJS in laravel project

我正在尝试将 Font Awesome 与 Vue + laravel 项目一起使用。

我有它在我的 package.json

"devDependencies": {
        "@fortawesome/fontawesome-free": "^5.15.4",
        "axios": "^0.21.4",
        "bootstrap": "^4.6.0",
        "jquery": "^3.6",
        "laravel-mix": "^6.0.34",
        "lodash": "^4.17.19",
        "popper.js": "^1.16.1",
        "postcss": "^8.3.11",
        "resolve-url-loader": "^3.1.4",
        "sass": "^1.43.3",
        "sass-loader": "^11.0.1",
        "vue": "^2.6.14",
        "vue-loader": "^15.9.8",
        "vue-template-compiler": "^2.6.14"
    },

main.js

中导入了 FontAwesome
import { library } from '@fortawesome/fontawesome-svg-core'
import { faSpinner } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'

我正在使用:

<i class="fas fa-ellipsis-v"></i>

但不显示图标!!

阅读文件 https://github.com/FortAwesome/vue-fontawesome

您需要添加到 main.js

Vue.component('font-awesome-icon', FontAwesomeIcon)

并使用标签 <font-awesome-icon icon="***" />

示例:

<font-awesome-icon icon="ellipsis-v" />