Skip to content

Instantly share code, notes, and snippets.

@afontcu
Created July 30, 2018 16:19
Show Gist options
  • Save afontcu/3741ace9c883871b0aa8ca5bb1234bc9 to your computer and use it in GitHub Desktop.
Save afontcu/3741ace9c883871b0aa8ca5bb1234bc9 to your computer and use it in GitHub Desktop.
<script>
import Vue from 'vue'
const state = new Vue({
data () {
return { red: 0, blue: 0 }
},
methods: {
voteForRed () { this.red++ },
voteForBlue () { this.blue++ },
},
})
const TotalVotes = {
render: h => h('div', `Total votes: ${state.red + state.blue}`),
}
const Results = {
render: h => h('div', `Red: ${state.red} - Blue: ${state.blue}`),
}
export default {
components: { TotalVotes, Results },
methods: {
voteForRed () { state.voteForRed() },
voteForBlue () { state.voteForBlue() },
},
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment