Replies: 2 comments 2 replies
-
Hi! Try using a hydration directive such as If it works as expected, it means that the component needs JS to work. I'd suggest using |
Beta Was this translation helpful? Give feedback.
1 reply
-
For any other who ran into the same problem and want less hassles (it seems that use the following component instead of <script setup lang="ts">
import { findIconDefinition, parse } from '@fortawesome/fontawesome-svg-core'
const props = defineProps({
icon: {
type: String,
required: true,
},
})
const lookup = parse.icon(props.icon)
const def = findIconDefinition(lookup)
const classes = [
'svg-inline--fa',
`fa-${lookup.iconName}`,
]
</script>
<template>
<svg
:class="classes"
aria-hidden="true"
focusable="false"
role="img"
xmlns="http://www.w3.org/2000/svg"
:viewBox="`0 0 ${def.icon[0]} ${def.icon[1]}`"
:data-prefix="lookup.prefix"
:data-icon="lookup.iconName"
>
<path fill="currentColor" :d="def.icon[4]"></path>
</svg>
</template>
<style lang="scss">
.svg-inline--fa {
display: var(--fa-display, inline-block);
height: 1em;
overflow: visible;
vertical-align: -0.125em;
}
svg:not(:root).svg-inline--fa, svg:not(:host).svg-inline--fa {
overflow: visible;
box-sizing: content-box;
}
</style>
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using fontawesome 6, it was imported and used like following
it works fine in dev mode, but once it's built, the icon is gone completely.
I suspect because the icons are loaded asynchonously (there is a loading icon before showing the real icon itself, don't know if this is how fontawesome works nowadays), and iles did not wait it to finish loading before capture the html.
I searched this problem with vite/vuejs a lot, nothing came out helpful. So I presume it might be async loading issue.
Beta Was this translation helpful? Give feedback.
All reactions