Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use as dynamic element #147

Closed
binaryben opened this issue Jan 5, 2022 · 1 comment
Closed

Unable to use as dynamic element #147

binaryben opened this issue Jan 5, 2022 · 1 comment

Comments

@binaryben
Copy link

I'm trying to allow an icon to be inserted into another component via a prop.

This is the (simplified) component:

<template>
  <template v-if="icon">
    <component :is="icon" />
  </template>
  <input />
</template>

<script setup lang="ts">
  defineProps<{
    icon?: string
    placeholder?: string
  }>()
</script>

And elsewhere I am doing this:

<Input icon="i-mdi-search" />
<i-mdi-search />

This results in the following DOM:

<i-mdi-search></i-mdi-search>
<input>
<svg>
    <!-- Icon inserted correctly -->
</svg>

Is there a way to make the icon work with the <component :is= ... feature of Vue? Alternatively, could a generic icon component be provided as part of the extension itself that uses a prop?

@antfu
Copy link
Member

antfu commented Jan 5, 2022

#5 (comment)

@antfu antfu closed this as completed Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants