Answer the question
In order to leave comments, you need to log in
Multiple choice?
Tell me if it is possible to select the desired component in the template based on some parameters, let everything depend on the parameter x , if(x === 1) is component A, if 2 is B and so on. I found only one way, use if else if, where we compare the values, and display the desired component. Perhaps there are better ways?
<A v-if="x === 1">
<B v-else-if="x === 2">
...
Answer the question
In order to leave comments, you need to log in
<component :is="x === 1 ? A : B" />
Also works with strings if components are registered locally/globally/generally from HTML:
<component :is="x === 1 ? 'div' : 'my-component'"></component>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question