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

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


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.


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