Tugann Vue sonas speisialta :class agus :style do syntax réada agus eolaire ionas gur féidir leat ranganna agus stíleanna i-líne a chur i bhfeidhm go coinníollach bunaithe ar stát atharraingtheach — níos geal ná téada rang a thógáil a láimh.
Object syntax do :class — ranganna a bhogadh de réir coinníoill
<script setup>
import { ref } from "vue";
const isActive = ref(true);
const hasError = ref(false);
</script>
<template>
<!-- a class is applied when its value is truthy -->
<div :class="{ active: isActive, 'text-red': hasError }">...</div>
<!-- renders class="active" (active=true, text-red=false) -->
</template>
