File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ export default class Todo extends Vue {
3131 @module . Getter ( types . getter . filterTodos ) todos
3232
3333 @module . Mutation ( types . mutation . setFilter ) setFilter
34+ @module . Mutation ( types . mutation . clearData ) clearData
3435
3536 @module . Action ( types . action . fetch ) fetch
3637 @module . Action ( types . action . save ) save
@@ -49,4 +50,9 @@ export default class Todo extends Vue {
4950 this . setFilter ( this . $route . params . filter )
5051 }
5152 }
53+
54+ beforeDestroy ( ) {
55+ // 理论上是要清除掉大数据,但是这里 filter 使用链接的方式,所以不需要清掉
56+ // this.clearData()
57+ }
5258}
Original file line number Diff line number Diff line change @@ -77,6 +77,11 @@ let mutations = mutation(state, {
7777
7878 clearComplete ( state ) {
7979 state . todos = state . todos . filter ( v => ! v . completed )
80+ } ,
81+
82+ clearData ( ) {
83+ // 将大数据重置,以免一直存在内存
84+ state . todos = [ ]
8085 }
8186} )
8287
You can’t perform that action at this time.
0 commit comments