Skip to content

Instantly share code, notes, and snippets.

@afontcu
Created July 30, 2018 16:05
Show Gist options
  • Save afontcu/29233c67f945da590be8f5e2c7c1163a to your computer and use it in GitHub Desktop.
Save afontcu/29233c67f945da590be8f5e2c7c1163a 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/>
<total-votes/>
</div>
</template>
<script>
const state = {
red: 0,
blue: 0,
}
const TotalVotes = {
data () { return state },
render (h) {
return h('div', `Total votes: ${this.red + this.blue}`)
},
}
const Results = {
data () { return state },
render (h) {
return h('div', `Red: ${this.red} - Blue: ${this.blue}`)
},
}
export default {
components: { TotalVotes, Results },
data () { return state },
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