I got the elements created by v-for, and i want to give different css classes these elements according to data.To do that I need a way to reach activeNumbers without v-for or use v-for without itteration.
<template>
<div v-for"n in 20" class="tables" :class="activeClass : activeNumbers == number">{{n}}
</div>
</template>
<script>
data(){
return {
activeNumbers:["1","5","8","9","17","12","19"]
}
}
</script>
<style>
.activeClass{
background: red;
}
.tables{
border:4px solid;
max-width: 120px;
width: 80%;
display: inline-block;
}
</style>
i tried to use tags to reach activeNumber but it does not work.
If I understand what you're looking for, you want to conditionally add your class if
n
is inactiveNumbers
. If so, here's what you would need to do:This sets the class to
activeClass
ifn
is inactiveNumbers
or nothing if not. Let me know if this is what you're looking for.