mirror of
https://github.com/Dichgrem/Vue.git
synced 2025-12-16 21:51:59 -05:00
feat:console_log
This commit is contained in:
@@ -30,36 +30,44 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
// 添加待办
|
|
||||||
addTodo(newTodo) {
|
addTodo(newTodo) {
|
||||||
this.todos.push({
|
const todo = {
|
||||||
id: Date.now(),
|
id: Date.now(),
|
||||||
txt: newTodo,
|
txt: newTodo,
|
||||||
completed: false,
|
completed: false,
|
||||||
});
|
};
|
||||||
|
this.todos.push(todo);
|
||||||
|
console.log("添加 Todo:", todo);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 删除待办
|
|
||||||
delTodo(item) {
|
delTodo(item) {
|
||||||
|
console.log("删除 Todo:", item);
|
||||||
this.todos = this.todos.filter((t) => t.id !== item.id);
|
this.todos = this.todos.filter((t) => t.id !== item.id);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
toggleTodo(item) {
|
||||||
|
console.log("完成状态切换:", item);
|
||||||
|
},
|
||||||
|
|
||||||
changeTabType(type) {
|
changeTabType(type) {
|
||||||
|
console.log("切换 Tab:", type);
|
||||||
this.tabType = type;
|
this.tabType = type;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// 深度监听 — 自动写入 localStorage
|
|
||||||
watch: {
|
watch: {
|
||||||
todos: {
|
todos: {
|
||||||
handler(todos) {
|
handler(todos) {
|
||||||
|
console.log("Todos 改变:", todos);
|
||||||
localStorage.setItem("vue-todos", JSON.stringify(todos));
|
localStorage.setItem("vue-todos", JSON.stringify(todos));
|
||||||
},
|
},
|
||||||
deep: true,
|
deep: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
Reference in New Issue
Block a user