I have a component which will have many div elements, with only one having an 'active' class on click. I'm trying to bind the 'active' class if a variable 'activeSlide' is equal to the element.
v-bind:class="{ 'active': activeSlide === ?? }"
I'm just not sure what the ?? should be. I haven't been able to find anything that tells how an element can reference itself. Or maybe there is a better approach?
My Code in .vue component file:
<template>
<div v-on:click="show" v-bind:class="{ 'active': activeSlide === ?? }"></div>
</template>
<script>
export default {
data() {
return {
activeSlide: null
}
}
methods: {
show: function(e) {
this.activeSlide = e.target;
}
}
}
</script>