vue v-if code example
Example 1: v-if vuejs
<h1 v-if="awesome">Vue is awesome !</h1>
<h1 v-else-if="sowSow">Vue is not very nice !</h1>
<h1 v-else>Vue is baaaad !</h1>
Example 2: vue v-if
<div v-if="Math.random() > 0.5">
Now you see me
</div>
<div v-else>
Now you don't
</div>
Example 3: vuejs v-for array index
<!-- To gain access to the array index: -->
<ul>
<li v-for="(game, index) in games"></li>
</ul>
<!--
You only want the index in specific cases. Use `:key` as
standard. See the other greps.
-->
Example 4: vue v-if compare string
<span v-for="role in user.roles">
<span v-if="role.name == 'Admin'">Yes</span>
<span v-else>-</span>
</span>
Example 5: v-for
<ul>
<li v-for="(item, index) in items">
{{ index }} - {{ item }}
</li>
</ul>
Example 6: vue if
<h1 v-if="variable">Vue is awesome!</h1>