Skip to content

Instantly share code, notes, and snippets.

/Counter.vue Secret

Created January 17, 2018 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/76cbabdd6a2ac849a84e85fc6ad99a7a to your computer and use it in GitHub Desktop.
Save anonymous/76cbabdd6a2ac849a84e85fc6ad99a7a to your computer and use it in GitHub Desktop.
<template>
<div class="counter">
<div class="col-md-6 col-md-offset-3 well">
<h1>Contador con Vuejs 2, Vuex y Socket.IO</h1>
<div class="clearfix"><hr /></div>
<button class="btn btn-block btn-info" @click="increment">
Incrementar
</button>
<h4 class="text-center">{{ count }}</h4>
<button class="btn btn-block btn-info" @click="decrement">
Decrementar
</button>
</div>
</div>
</template>
<script>
export default {
methods: {
increment () {
this.$store.dispatch('socket_increment')
},
decrement () {
this.$store.dispatch('socket_decrement')
}
},
computed: {
count () {
return this.$store.state.counterModule.count
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment