Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vue.js

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.

like image 423
Hasibul- Avatar asked Mar 11 '18 08:03

Hasibul-


People also ask

Can I use V-for with V-if?

v-if with v-forIt's not recommended to use v-if and v-for on the same element due to implicit precedence.

What is V else if?

v-else-if directive is a Vue. js directive used to toggle the display CSS property of an element depending on a condition when the if condition is not satisfied.

How is V-HTML different from V text?

The v-html directive is used to update a element's innerHTML with our data. This is what separates it from v-text which means while v-text accepts string and treats it as a string it will accept string and render it into HTML.

What is V-for in HTML?

v-for. We can use the v-for directive to render a list of items based on an array. The v-for directive requires a special syntax in the form of item in items , where items is the source data array and item is an alias for the array element being iterated on: js const items = ref([{ message: 'Foo' }, { message: 'Bar' } ...


1 Answers

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.

like image 161
Bhojendra Rauniyar Avatar answered Oct 17 '22 14:10

Bhojendra Rauniyar