Nuxt/examples/vuex-store/pages/index.vue
Sébastien Chopin 381ef89eb0 code style
2017-08-13 22:11:51 +02:00

29 lines
514 B
Vue

<template>
<div>
<p>
<button @click="increment">{{ counter }}</button><br>
<nuxt-link to="/about">About</nuxt-link>
</p>
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
// fetch(context) is called by the server-side
// and nuxt before instantiating the component
fetch ({ store }) {
store.commit('increment')
},
computed: mapState([
'counter'
]),
methods: {
increment () {
this.$store.commit('increment')
}
}
}
</script>