Created
July 30, 2018 16:19
-
-
Save afontcu/3741ace9c883871b0aa8ca5bb1234bc9 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
<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