Skip to content

Commit c3e6101

Browse files
committed
update
1 parent 1537b53 commit c3e6101

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

vuejs入门基础/my-second-vue-project/src/App.vue

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,43 @@
11
<template>
22
<div id="app">
33
<h1 v-text="title"></h1>
4+
<input v-model="newItem" v-on:keyup.enter="addNew">
45
<ul>
5-
<li v-for="item in items" v-bind:class="{finished:item.isFinished}">
6+
<li v-for="item in items" v-bind:class="{finished:item.isFinished}" v-on:click="toggleFinish(item)">
67
{{item.label}}
78
</li>
89
</ul>
910
</div>
1011
</template>
1112

1213
<script>
14+
import Store from './store'
15+
1316
1417
export default {
1518
data:function(){
1619
return {
1720
title:'this is a todo list',
1821
items:[
1922
{label:'coding',isFinished:false
20-
},{
23+
},{
2124
label:'walking',isFinished:true
2225
}],
26+
newItem:'',
2327
liClass:'thisisliClass'
2428
};
25-
29+
},
30+
methods:{
31+
toggleFinish:function(item){
32+
item.isFinished = !item.isFinished;
33+
},
34+
addNew:function(){
35+
this.items.push({
36+
label:this.newItem,
37+
isFinished:false,
38+
});
39+
this.newItem = '';
40+
}
2641
}
2742
}
2843
</script>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const STORAGE_KEY = 'todos-vuejs'
2+
export default{
3+
fetch(){
4+
return JSON.parse(window.localStorage.getItem(STORAGE_KEY) || '[]');
5+
},
6+
save(items){
7+
window.localStorage.setItem(STORAGE_KEY,JSON.stringify(items));
8+
}
9+
}

0 commit comments

Comments
 (0)