Skip to content

Instantly share code, notes, and snippets.

@seanbrwh
Created August 16, 2019 17:53
Show Gist options
  • Save seanbrwh/e688f92d2c1b1ff2178b4f756836d7cb to your computer and use it in GitHub Desktop.
Save seanbrwh/e688f92d2c1b1ff2178b4f756836d7cb to your computer and use it in GitHub Desktop.
mdbEVqa
<div id='app'>
<div
v-for="date in daysInMonth" :key='date.id'
class='main'
:class={'active':date.active}
@click='toggleDay(date)'
>
{{date.value}}
</div>
</div>
var app = new Vue({
el: "#app",
data: {
},
computed:{
daysInMonth(){
return this.createDaysInMothArr()
}
},
methods: {
toggleDay(day){
day.active = !day.active
},
createDaysInMothArr(){
var count = 123
var daysLen = 31
var daysInMonth = []
for(var i = 1; i <= daysLen; i++){
daysInMonth.push({
index:count++,
value:i,
active:false
})
}
return daysInMonth
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"></script>
.main{
display:flex;
justify-content:space-evenly;
align-items:center;
}
.active{
background:red
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment