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

45 lines
742 B
Vue
Raw Normal View History

<template>
<div>
<h3>Index Module</h3>
<button @click="increment">
{{ counter }}
</button>
<br>
<NuxtLink to="/about">
About
</NuxtLink>
<br>
<br>
<h3>Todo Module</h3>
<NuxtLink to="/todos">
Todos
</NuxtLink>
<br>
<br>
<h3>Nested Modules</h3>
<NuxtLink to="/website">
Website
</NuxtLink>
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
2019-02-18 10:44:03 +00:00
computed: mapState([
'counter'
]),
// fetch(context) is called by the server-side
// and before instantiating the component
2017-10-31 13:43:55 +00:00
fetch({ store }) {
store.commit('increment')
},
methods: {
2017-10-31 13:43:55 +00:00
increment() {
2017-08-13 20:11:51 +00:00
this.$store.commit('increment')
}
}
}
</script>