Vue memberikan :class dan :style sintaks objek dan array khusus sehingga anda dapat menerapkan kelas dan gaya sebaris secara bersyarat berdasarkan keadaan reaktif — lebih bersih daripada membangun string kelas secara manual.
Sintaks objek untuk :class — togol kelas mengikut syarat
<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>
