diff --git a/20_脚手架/vue_code/06.src_todoList练习/App.vue b/20_脚手架/vue_code/06.src_todoList练习/App.vue new file mode 100644 index 0000000..335b63b --- /dev/null +++ b/20_脚手架/vue_code/06.src_todoList练习/App.vue @@ -0,0 +1,114 @@ + + + + + \ No newline at end of file diff --git a/20_脚手架/vue_code/06.src_todoList练习/assets/logo.png b/20_脚手架/vue_code/06.src_todoList练习/assets/logo.png new file mode 100644 index 0000000..f3d2503 Binary files /dev/null and b/20_脚手架/vue_code/06.src_todoList练习/assets/logo.png differ diff --git a/20_脚手架/vue_code/06.src_todoList练习/components/TodoBottom.vue b/20_脚手架/vue_code/06.src_todoList练习/components/TodoBottom.vue new file mode 100644 index 0000000..4ac67d0 --- /dev/null +++ b/20_脚手架/vue_code/06.src_todoList练习/components/TodoBottom.vue @@ -0,0 +1,74 @@ + + + + + \ No newline at end of file diff --git a/20_脚手架/vue_code/06.src_todoList练习/components/TodoHeader.vue b/20_脚手架/vue_code/06.src_todoList练习/components/TodoHeader.vue new file mode 100644 index 0000000..b0c7dca --- /dev/null +++ b/20_脚手架/vue_code/06.src_todoList练习/components/TodoHeader.vue @@ -0,0 +1,48 @@ + + + + + \ No newline at end of file diff --git a/20_脚手架/vue_code/06.src_todoList练习/components/TodoItem.vue b/20_脚手架/vue_code/06.src_todoList练习/components/TodoItem.vue new file mode 100644 index 0000000..b565bdc --- /dev/null +++ b/20_脚手架/vue_code/06.src_todoList练习/components/TodoItem.vue @@ -0,0 +1,74 @@ + + + + + \ No newline at end of file diff --git a/20_脚手架/vue_code/06.src_todoList练习/components/TodoList.vue b/20_脚手架/vue_code/06.src_todoList练习/components/TodoList.vue new file mode 100644 index 0000000..4d241f2 --- /dev/null +++ b/20_脚手架/vue_code/06.src_todoList练习/components/TodoList.vue @@ -0,0 +1,41 @@ + + + + + \ No newline at end of file diff --git a/20_脚手架/vue_code/06.src_todoList练习/main.js b/20_脚手架/vue_code/06.src_todoList练习/main.js new file mode 100644 index 0000000..30ef712 --- /dev/null +++ b/20_脚手架/vue_code/06.src_todoList练习/main.js @@ -0,0 +1,16 @@ +// 引入Vue +import Vue from "vue"; +// 引入App +import App from "./App"; + +// 设置Vue +Vue.config.productionTip = false + + +// 实例化Vue +new Vue({ + components: { + App + }, + render: h => h(App) +}).$mount('#app') diff --git a/20_脚手架/vue_code/07.src_todoList本地存储/App.vue b/20_脚手架/vue_code/07.src_todoList本地存储/App.vue new file mode 100644 index 0000000..4d51efe --- /dev/null +++ b/20_脚手架/vue_code/07.src_todoList本地存储/App.vue @@ -0,0 +1,118 @@ + + + + + \ No newline at end of file diff --git a/20_脚手架/vue_code/07.src_todoList本地存储/assets/logo.png b/20_脚手架/vue_code/07.src_todoList本地存储/assets/logo.png new file mode 100644 index 0000000..f3d2503 Binary files /dev/null and b/20_脚手架/vue_code/07.src_todoList本地存储/assets/logo.png differ diff --git a/20_脚手架/vue_code/07.src_todoList本地存储/components/TodoBottom.vue b/20_脚手架/vue_code/07.src_todoList本地存储/components/TodoBottom.vue new file mode 100644 index 0000000..4ac67d0 --- /dev/null +++ b/20_脚手架/vue_code/07.src_todoList本地存储/components/TodoBottom.vue @@ -0,0 +1,74 @@ + + + + + \ No newline at end of file diff --git a/20_脚手架/vue_code/07.src_todoList本地存储/components/TodoHeader.vue b/20_脚手架/vue_code/07.src_todoList本地存储/components/TodoHeader.vue new file mode 100644 index 0000000..b0c7dca --- /dev/null +++ b/20_脚手架/vue_code/07.src_todoList本地存储/components/TodoHeader.vue @@ -0,0 +1,48 @@ + + + + + \ No newline at end of file diff --git a/20_脚手架/vue_code/07.src_todoList本地存储/components/TodoItem.vue b/20_脚手架/vue_code/07.src_todoList本地存储/components/TodoItem.vue new file mode 100644 index 0000000..b565bdc --- /dev/null +++ b/20_脚手架/vue_code/07.src_todoList本地存储/components/TodoItem.vue @@ -0,0 +1,74 @@ + + + + + \ No newline at end of file diff --git a/20_脚手架/vue_code/07.src_todoList本地存储/components/TodoList.vue b/20_脚手架/vue_code/07.src_todoList本地存储/components/TodoList.vue new file mode 100644 index 0000000..4d241f2 --- /dev/null +++ b/20_脚手架/vue_code/07.src_todoList本地存储/components/TodoList.vue @@ -0,0 +1,41 @@ + + + + + \ No newline at end of file diff --git a/20_脚手架/vue_code/07.src_todoList本地存储/main.js b/20_脚手架/vue_code/07.src_todoList本地存储/main.js new file mode 100644 index 0000000..30ef712 --- /dev/null +++ b/20_脚手架/vue_code/07.src_todoList本地存储/main.js @@ -0,0 +1,16 @@ +// 引入Vue +import Vue from "vue"; +// 引入App +import App from "./App"; + +// 设置Vue +Vue.config.productionTip = false + + +// 实例化Vue +new Vue({ + components: { + App + }, + render: h => h(App) +}).$mount('#app') diff --git a/20_脚手架/vue_code/src/App.vue b/20_脚手架/vue_code/src/App.vue index 335b63b..4d51efe 100644 --- a/20_脚手架/vue_code/src/App.vue +++ b/20_脚手架/vue_code/src/App.vue @@ -26,11 +26,7 @@ export default { data() { return { // 预置测试数据 - todos: [ - {id: "001", title: "产品", done: true}, - {id: "002", title: "开发", done: true}, - {id: "003", title: "测试", done: false} - ] + todos: JSON.parse(localStorage.getItem('todos')) || [] } }, // 由于数据需要被不同的子组件访问,暂时没有学习数据的处理方法,所以将数据放置在父组件App中 @@ -64,6 +60,14 @@ export default { return !todo.done }) } + }, + watch: { + todos: { + deep: true, + handler(value) { + localStorage.setItem('todos', JSON.stringify(value)) + } + } } }