⊗jsvuPmCdVE 22 of 72 menu

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.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline