updated example for nested modules

This commit is contained in:
Ralph Huwiler 2017-03-25 23:04:34 +01:00
parent 78ea2591c2
commit 6f66cd0a1f
4 changed files with 78 additions and 0 deletions

View File

@ -1,11 +1,18 @@
<template>
<div>
<p>
<h3>Index Module</h3>
<button @click="increment">{{ counter }}</button>
<br>
<nuxt-link to="/about">About</nuxt-link>
<br>
<br>
<h3>Todo Module</h3>
<nuxt-link to="/todos">Todos</nuxt-link>
<br>
<br>
<h3>Nested Modules</h3>
<nuxt-link to="/website">Website</nuxt-link>
</p>
</div>
</template>

View 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>

View 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
}
}

View 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
}
}