mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-17 06:01:34 +00:00
updated example for nested modules
This commit is contained in:
parent
78ea2591c2
commit
6f66cd0a1f
@ -1,11 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<p>
|
<p>
|
||||||
|
<h3>Index Module</h3>
|
||||||
<button @click="increment">{{ counter }}</button>
|
<button @click="increment">{{ counter }}</button>
|
||||||
<br>
|
<br>
|
||||||
<nuxt-link to="/about">About</nuxt-link>
|
<nuxt-link to="/about">About</nuxt-link>
|
||||||
<br>
|
<br>
|
||||||
|
<br>
|
||||||
|
<h3>Todo Module</h3>
|
||||||
<nuxt-link to="/todos">Todos</nuxt-link>
|
<nuxt-link to="/todos">Todos</nuxt-link>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<h3>Nested Modules</h3>
|
||||||
|
<nuxt-link to="/website">Website</nuxt-link>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
33
examples/vuex-store-modules/pages/website.vue
Normal file
33
examples/vuex-store-modules/pages/website.vue
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h2>Articles</h2>
|
||||||
|
<ul>
|
||||||
|
<li v-for="article in articles">
|
||||||
|
<span>{{article}}</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<h2>Comments <small>(nested under articles)</small></h2>
|
||||||
|
<ul>
|
||||||
|
<li v-for="comment in comments">
|
||||||
|
<span>{{comment}}</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<nuxt-link to="/">Home</nuxt-link>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapGetters } from 'vuex'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
computed: mapGetters({
|
||||||
|
articles: 'articles/get',
|
||||||
|
comments: 'articles/comments/get'
|
||||||
|
}),
|
||||||
|
methods: {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
19
examples/vuex-store-modules/store/articles.js
Normal file
19
examples/vuex-store-modules/store/articles.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
export const state = {
|
||||||
|
list: [
|
||||||
|
'Lorem ipsum',
|
||||||
|
'dolor sit amet',
|
||||||
|
'consetetur sadipscing elitr'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const mutations = {
|
||||||
|
add (state, title) {
|
||||||
|
state.list.push(title)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getters = {
|
||||||
|
get (state) {
|
||||||
|
return state.list
|
||||||
|
}
|
||||||
|
}
|
19
examples/vuex-store-modules/store/articles/comments.js
Normal file
19
examples/vuex-store-modules/store/articles/comments.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
export const state = {
|
||||||
|
list: [
|
||||||
|
'Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
|
||||||
|
'Lorem ipsum dolor sit amet, consetetur sadipscing elit.',
|
||||||
|
'Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const mutations = {
|
||||||
|
add (state, title) {
|
||||||
|
state.list.push(title)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getters = {
|
||||||
|
get (state) {
|
||||||
|
return state.list
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user