[Vuejs]-Add dynamic attribute value (or css selector value) in style using scss lang in Vue 3?

0👍

Try to use conditional class binding as follows :

<script setup lang="ts">
const currentSelectedId = ref(1);
</script>
<template>
  <row  v-for="i in 3" :class="{selected:i===currentSelectedId}" class="b-grid-row" data-id="1"></row>
</template>
<style lang="scss">
.b-grid-row.selected{
  background-color: blue;
}
</style>

Leave a comment