Last active
July 30, 2018 15:42
-
-
Save afontcu/a0ca1102d0400fb6708b8ceb299f9b9b to your computer and use it in GitHub Desktop.
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
<template> | |
<div> | |
<h1>Election day!</h1> | |
<button @click="voteForRed">Vote for 🔴</button> | |
<button @click="voteForBlue">Vote for 🔵</button> | |
<h2>Results</h2> | |
<results :red="red" :blue="blue" /> | |
<total-votes :total="red + blue" /> | |
</div> | |
</template> | |
<script> | |
const TotalVotes = { | |
props: ['total'], | |
render (h) { | |
return h('div', `Total votes: ${this.total}`) | |
} | |
} | |
const Results = { | |
props: ['red', 'blue'], | |
render (h) { | |
return h('div', `Red: ${this.red} - Blue: ${this.blue}`) | |
} | |
} | |
export default { | |
components: { TotalVotes, Results, }, | |
data: () => ({ red: 0, blue: 0 }), | |
methods: { | |
voteForRed () { this.red++ }, | |
voteForBlue () { this.blue++ }, | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment