A Pen by Sean White on CodePen.
Created
August 16, 2019 17:53
-
-
Save seanbrwh/e688f92d2c1b1ff2178b4f756836d7cb to your computer and use it in GitHub Desktop.
mdbEVqa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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