Skip to content

Instantly share code, notes, and snippets.

@afontcu
Last active July 30, 2018 15:42
Show Gist options
  • Save afontcu/a0ca1102d0400fb6708b8ceb299f9b9b to your computer and use it in GitHub Desktop.
Save afontcu/a0ca1102d0400fb6708b8ceb299f9b9b to your computer and use it in GitHub Desktop.
<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