Answer the question
In order to leave comments, you need to log in
How to load different templates in a Vue component, leaving the contents of the JS code untouched?
Good day!
I have a Vue component. Depending on the situation, it is necessary to load different template code into the section, while leaving all the JS untouched. You can of course do something like this:
<template>
<div v-if="situation1">
(шаблон 1)
</div>
<div v-else>
(шаблон 2)
</div>
</template>
<script>
(одинаковый код для обоих шаблонов)
</script>
Answer the question
In order to leave comments, you need to log in
<template>
<div>
<component :is="ComponentDependingOnTheCondition">
</div>
</template>
<script>
(одинаковый код для обоих шаблонов)
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question