I currently have a grid of blank squares made from divs. When I click on a grid space, the entire grid changes colour. I'm trying to just get the square(div) I click on to change colour. This is what my code looks like. Any help would be appreciated.
<div id="app">
<section class="grid-container">
<div :style="isClicked ? {'background': 'green'} : null" @click="toggleIsClicked" v-for="square in grid" :square="square" v-bind:class="space">{{square}}</div>
</section>
</div>
<script>
var app = new Vue({
el: '#app',
props: ['square'],
data:{
isClicked: false,
space: "space",
grid:
["","","","","","","","","","",
"","","","","","","","","","",
"","","","","","","","","","",
"","","","","","","","","","",
"","","","","","","","","","",
"","","","","","","","","","",
"","","","","","","","","","",
"","","","","","","","","","",
"","","","","","","","","","",
"","","","","","","","","",""]
},
methods:{
toggleIsClicked : function() {
if(!this.isClicked){
this.isClicked = true;
console.log(this.key);
}else{
this.isClicked = false;
}
},
}
});
</script>