mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-23 09:00:31 +00:00
30 lines
569 B
Vue
30 lines
569 B
Vue
|
<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
|
||
|
// and nuxt before instantiating the component
|
||
|
fetch ({ store }) {
|
||
|
store.commit('increment')
|
||
|
},
|
||
|
computed: mapState([
|
||
|
'counter'
|
||
|
]),
|
||
|
methods: {
|
||
|
increment () { this.$store.commit('increment') }
|
||
|
}
|
||
|
}
|
||
|
</script>
|