fontawesome error “Could not find one or more icon”

笑着哭i 提交于 2019-12-03 17:39:05

问题


I followed https://fontawesome.com/how-to-use/on-the-web/using-with/vuejs.

But when use it like:

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"/>

Got:

Could not find one or more icon(s) {prefix: "fas", iconName: "twitter"}


回答1:


free-brands-svg-icons use the fab prefix (docs don't appear to mention this, had to check its folder in node_modules), which you have to specify:

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

When non specified, fas prefix is assumed.

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



来源:https://stackoverflow.com/questions/51207263/fontawesome-error-could-not-find-one-or-more-icon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!