0

My actual code:

    <component :is="type === 'v-text-field'">
      <v-text-field v-bind="props" />
    </component>
    <component :is="type === 'v-autocomplete'">
      <v-autocomplete v-bind="props" />
    </component>

I would like to be more cleaner, like this:

<:type v-bind="props" />

I know my code above is wrong, but I would like to replace that type with a vuetify component.

1 Answer 1

2

In the Vue.js dynamic components documentation, the special is attribute can container either:

  • the name string of a registered component, OR
  • the actual imported component object

But you are providing it with a boolean instead.

As far as I understand, this line should be enough:

<component :is="type" v-bind="props">
Sign up to request clarification or add additional context in comments.

1 Comment

I just noticed I'm being redundant, because I'm trying to clean my code, creating more code. lol...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.