fontawesome error "Could not find one or more icon"
Asked Answered
A

3

23

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

Abduction answered 6/7, 2018 at 9:30 Comment(0)
F
53

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

Fractionate answered 6/7, 2018 at 10:42 Comment(2)
This is a correct answer. Except that there are some documents that describe this. Upgrading from Version 4: fontawesome.com/how-to-use/on-the-web/setup/… . That describes the various style prefixes—relevant to any use of Font Awesome 5. And the README on vue-fontawesome discusses the Vue syntax for specifying prefixes other than the default fas. Here: github.com/FortAwesome/vue-fontawesome#the-icon-property and Here: github.com/FortAwesome/…Hawfinch
Is there a way to globally set a prefix? For example, I never solid - I always use fal, but I don't want to type it on every icon line.Stipel
F
0

I had to dig into the linked sandbox to find the answer I was looking for.

<template>
...
   <!-- For "normal" icons, do not use the prefix -->
   <font-awesome-icon icon='bars' />

   <!-- For "brands", use more verbose prop definition -->
   <font-awesome-icon :icon="['fab', 'fab-twitter']" />
...
</template>

Frivol answered 28/4, 2022 at 13:38 Comment(1)
you typo, it shoud be: <font-awesome-icon :icon="['fab', 'fab-twitter']" />Sprue
A
0

I resolved it by dynamically binding the icons which now read like this

<font-awesome-icon :icon="['fas', 'user-secret']" />
Appointive answered 21/3, 2024 at 10:42 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.