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

Dynamic components: Unable to use component v-bind:is= #180

Closed
Codermar opened this issue Mar 25, 2022 · 1 comment
Closed

Dynamic components: Unable to use component v-bind:is= #180

Codermar opened this issue Mar 25, 2022 · 1 comment

Comments

@Codermar
Copy link

Codermar commented Mar 25, 2022

Hi,
I am enjoying using your plugin immensely. Thanks!

However, I have an action bar component where I would like to setup a button with a dynamic icon but the svg does not get rendered.

This is the partial code for my action bar component:

<button v-if="addButton && !addButton.hide" :class="{ reversed: addButton.reversed }" :data-cy="`${dataCy}-add`" @click.prevent.stop="$emit('add')">
  <SymbolPlusSquare width="20" height="20" :fill="addButton.fill || 'gray'" />
  <span v-if="addButton.label">{{ addButton.label }}</span>
</button>
<button v-if="customButton && !customButton.hide" :class="{ reversed: customButton.reversed }" :data-cy="`${dataCy}-custom`" @click.prevent.stop="$emit('custom')">
  <component v-bind:is="customButton.icon" v-if="customButton.icon" width="20" height="20" :fill="customButton.fill || 'gray'"></component>
  <span v-if="customButton.label">{{ customButton.label }}</span>
</button>

I am passing props: :customButton="{ label: null, icon: 'SymbolPlusSquare', label: 'My Action' }"

What gets rendered is:

<symbolplussquare data-v-9af60b78="" width="20" height="20" fill="gray"></symbolplussquare>

I am using Vue2/Vite 2.8.6 and

"unplugin-icons": "0.14.1",
"unplugin-vue-components": "0.18.4",
"unplugin-vue2-script-setup": "0.10.0",
"vite": "2.8.6",
"vite-plugin-components": "0.13.3",
@serfend
Copy link

serfend commented May 6, 2022

NOT SUPPORT THIS WAY for there is no way to infer a component from a dynamic string

@antfu antfu closed this as not planned Won't fix, can't repro, duplicate, stale Mar 3, 2023
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

3 participants