fontawesome错误“找不到一个或多个图标”

时间:2018-07-06 09:30:18

标签: vue.js font-awesome vuepress

我关注了https://fontawesome.com/how-to-use/on-the-web/using-with/vuejs

但是当像这样使用它时

import { library } from '@fortawesome/fontawesome-svg-core'
import { faBars } from '@fortawesome/free-solid-svg-icons'
import { faTwitter, faFacebook, faStackOverflow, faGithub } from '@fortawesome/free-brands-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'

...

library.add(faBars, faTwitter, faFacebook, faStackOverflow, faGithub )
Vue.component('font-awesome-icon', FontAwesomeIcon)

...

<font-awesome-icon icon="twitter" class="icon alt"/>

知道:

  

找不到一个或多个图标{前缀:“ fas”,iconName:“ twitter”}

1 个答案:

答案 0 :(得分:17)

free-brands-svg-icons使用 fab前缀(文档似乎没有提及这一点,必须在node_modules中检查其文件夹),您必须指定:

<font-awesome-icon :icon="['fab', 'twitter']" class="icon alt"/>

未指定时,fas prefix is assumed

CodeSandbox:https://codesandbox.io/s/6j833qp57k