Nuxt/examples/vuex-store-modules/pages/index.vue

30 lines
564 B
Vue
Raw Normal View History

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