How to use v-if and v-else without any html tag or else

vue.js

vue.js Problem Overview


List item

<ul>
 <li>language</li>
 
   < v-if= "tree()"> //which tag I may use or any other process
    <li>home</li>
    <li>about</li>
   <>
   < v-else> //which tag I may use or any other process
    <li>accounts</li>
    <li>listing</li>
   <>
</ul>'

In the V-if which html tag i may use or any other vue.js process to work with this.

vue.js Solutions


Solution 1 - vue.js

You can use template:

<template v-if="condition">
</template>
<template v-else>
</template>

Template will not be rendered in the browser. But it will parse the contents inside of this to the html.

Solution 2 - vue.js

you can sometimes use the <slot> element to make what you want. Have a look at the slot documentation here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHasibul-View Question on Stackoverflow
Solution 1 - vue.jsBhojendra RauniyarView Answer on Stackoverflow
Solution 2 - vue.jskevinnielView Answer on Stackoverflow