v-else directive in Vue
The v-if directive can also work in combination with v-else. Let's see how this looks in practice. Let the isAuth property contain whether the user is authorized or not:
data() {
return {
isAuth: true, // here it is either true or false
}
}
Let's make it so that depending on the value of isAuth, either one message or another is displayed:
<template>
<p v-if="isAuth">+++</p>
<p v-else>---</p>
</template>
Given property isAdmin:
data() {
return {
isAdmin: true,
}
}
Depending on the value of the property, output either one text or the other.