javascript - How to use @heroiconsvue in Nuxt3? - Stack Overflow

i want to import @heroiconsvue in Nuxt 3 but my icon not appear in frontend.my setup:import { HomeIc

i want to import @heroicons/vue in Nuxt 3 but my icon not appear in frontend.

my setup:

import { HomeIcon, FilmIcon, PlusIcon } from "@heroicons/vue/solid"

my html:

<template v-for="(profileItem, i) in accountSetFields" :key="i">
  <ProfileItems :user="user" :item="profileItem" />
    <template v-slot:icon>
      <ponent :is="profileItem.icon"></ponent>
    </template>
  </ProfileItems>
</template>

the variable profile.Item.icon has a string value of "HomeIcon"

I have tried to pass the value directly to the child ponent "ProfileItem.vue" but i receive the same error message.

When i pass the value directly as string ("HomeIcon" instead of profile.Item.icon) than it works because it mentioned the attribute from import { HomeIcon, FilmIcon, PlusIcon } from "@heroicons/vue/solid

<ponent :is="HomeIcon"></ponent>

Did anyone know how to load the icons dynamically?

i want to import @heroicons/vue in Nuxt 3 but my icon not appear in frontend.

my setup:

import { HomeIcon, FilmIcon, PlusIcon } from "@heroicons/vue/solid"

my html:

<template v-for="(profileItem, i) in accountSetFields" :key="i">
  <ProfileItems :user="user" :item="profileItem" />
    <template v-slot:icon>
      <ponent :is="profileItem.icon"></ponent>
    </template>
  </ProfileItems>
</template>

the variable profile.Item.icon has a string value of "HomeIcon"

I have tried to pass the value directly to the child ponent "ProfileItem.vue" but i receive the same error message.

When i pass the value directly as string ("HomeIcon" instead of profile.Item.icon) than it works because it mentioned the attribute from import { HomeIcon, FilmIcon, PlusIcon } from "@heroicons/vue/solid

<ponent :is="HomeIcon"></ponent>

Did anyone know how to load the icons dynamically?

Share Improve this question edited Nov 12, 2022 at 17:18 kissu 47k16 gold badges90 silver badges189 bronze badges asked Nov 12, 2022 at 15:42 user19540948user19540948
Add a ment  | 

2 Answers 2

Reset to default 4

That one works well

<script setup>
import { HomeIcon, FilmIcon, PlusIcon } from "@heroicons/vue/24/solid"

const icons = reactive({
  home: HomeIcon,
  film: FilmIcon,
  plus: PlusIcon,
})
</script>

<template>
  <ponent :is="icons.home"></ponent>
</template>

as explained here, you need the 24 in your import (for the size).


Not sure but this may also help maybe, didn't have to use that myself: https://github./tailwindlabs/heroicons/issues/564

Or you can forget about worrying about various icons configuration and fallback to that one (configured once and for all): https://stackoverflow./a/72055404/8816585

You can also use it without <ponent/> and register the icon as a ponent. Should also work with the position api.

<template>
   <CheckCircleIcon />
</template>

<script>
import { CheckCircleIcon } from "@heroicons/vue/24/solid";

export default {
  ponents: {
    CheckCircleIcon,
  }
}
</script>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744186816a4562242.html

相关推荐

  • javascript - How to use @heroiconsvue in Nuxt3? - Stack Overflow

    i want to import @heroiconsvue in Nuxt 3 but my icon not appear in frontend.my setup:import { HomeIc

    8天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信