⊗jsvuPmStDC 41 of 72 menu

CSS classes via data in Vue

CSS classes can be added to an element depending on the values ​​of the properties of the data object. Let's look at an example. Let's say we have the following properties:

data() { return { isActive: true, hasError: true, } }

Let's add CSS classes to the element depending on the value of our properties:

<template> <p :class="{active: isActive, error: hasError}"> text </p> </template>

The following properties are given:

data() { return { isValid: true, isDisabled: true, } }

Make sure that depending on the values ​​of these properties, the corresponding CSS classes are added to the tag.

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