Update examples

This commit is contained in:
Sébastien Chopin 2017-01-09 15:10:01 +01:00
parent 18c694d5ce
commit f8de9dbe0d
4 changed files with 8 additions and 12 deletions

View File

@ -10,7 +10,7 @@ export default {
layout: 'dark', layout: 'dark',
data ({ req }) { data ({ req }) {
return { return {
name: req ? 'server' : 'client2' name: req ? 'server' : 'client'
} }
} }
} }

View File

@ -15,7 +15,7 @@ import { mapState } from 'vuex'
export default { export default {
// fetch(context) is called by the server-side // fetch(context) is called by the server-side
// and nuxt before instantiating the component // and before instantiating the component
fetch ({ store }) { fetch ({ store }) {
store.commit('increment') store.commit('increment')
}, },

View File

@ -1,12 +1,12 @@
<template> <template>
<div> <div>
<h2>Todos</h2> <h2>Todos</h2>
<input placeholder="What needs to be done?" @keyup.enter="addTodo">
<ul> <ul>
<li v-for="todo in todos"> <li v-for="todo in todos">
<input type="checkbox" :checked="todo.done" @change="toggle({ todo })"> <input type="checkbox" :checked="todo.done" @change="toggle(todo)">
<label v-text="todo.text" @dblclick="editing = true"></label> <span :class="{ done: todo.done }">{{ todo.text }}</span>
</li> </li>
<li><input placeholder="What needs to be done?" @keyup.enter="addTodo"></li>
</ul> </ul>
<nuxt-link to="/">Home</nuxt-link> <nuxt-link to="/">Home</nuxt-link>
</div> </div>
@ -35,7 +35,7 @@ export default {
</script> </script>
<style> <style>
li { .done {
list-style: none; text-decoration: line-through;
} }
</style> </style>

View File

@ -10,11 +10,7 @@ export const mutations = {
}) })
}, },
delete (state, { todo }) { toggle (state, todo) {
state.list.splice(state.list.indexOf(todo), 1)
},
toggle (state, { todo }) {
todo.done = !todo.done todo.done = !todo.done
} }
} }