Closed ooooshino closed 4 months ago
https://tailwindcss.com/docs/content-configuration#dynamic-class-names
I think better replace const menuIcon = computed(() => props.icon ?
with i-mdi-light-${props.icon}
: '')const menuIcon = computed(() => props.icon || '')
, and pass a full class name asprops.icon
.
Close as this is not an issue. If you have any questions more, feel free to reopen it.
tried to import the mdi-light pack from iconify on my project. My tailwind.config.cjs file is correctly configured, and the plugin works fine. However, when I created a secondary component MenuItem, the icon did not display, and I didn’t receive any error messages.
Here’s the code for my MenuItem component:
I used the following code to import MenuItem in my menu:
I ran
pnpm dev
and didn’t see any icons on the page. Opening the console, the computed property had successfully changed the class toi-mdi-light-home
Strange thing is that after adding the complete class name to the span
<span :class="menuIcon" class="i-mdi-light-home" />
, the icon appeared on the page. However, even after removing the class, the icon remained visible on the page. But when the “pnpm dev” process was stopped using “ctrl+c” and started again, the icon disappeared again.Device information
dependencies