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

39 lines
743 B
Vue
Raw Normal View History

2016-12-26 14:55:00 +00:00
<template>
<div>
<p>
2017-03-25 22:04:34 +00:00
<h3>Index Module</h3>
2016-12-26 14:55:00 +00:00
<button @click="increment">{{ counter }}</button>
<br>
<nuxt-link to="/about">About</nuxt-link>
<br>
2017-03-25 22:04:34 +00:00
<br>
<h3>Todo Module</h3>
2016-12-26 14:55:00 +00:00
<nuxt-link to="/todos">Todos</nuxt-link>
2017-03-25 22:04:34 +00:00
<br>
<br>
<h3>Nested Modules</h3>
<nuxt-link to="/website">Website</nuxt-link>
2016-12-26 14:55:00 +00:00
</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: {
2017-08-13 20:19:19 +00:00
increment () {
this.$store.commit('increment')
}
2016-12-26 14:55:00 +00:00
}
}
</script>