no message

This commit is contained in:
chenxuan
2024-04-23 18:06:15 +08:00
parent 2c85466ad7
commit 37bf7664b0
+6
View File
@@ -16,6 +16,7 @@ class App extends React.Component {
{id:'009',name:'哄老婆',done:false},
{id:'010',name:'蹲坑',done:false}
]}
// 修改
updateTodo=(id,done)=>{
const {todos}=this.state
const newTodos=todos.map((i)=>{
@@ -28,6 +29,7 @@ class App extends React.Component {
})
this.setState({todos:newTodos})
}
// 删除
deleteTodo=(id)=>{
const {todos}=this.state
const newTodos=todos.filter((i)=>{
@@ -35,10 +37,13 @@ class App extends React.Component {
})
this.setState({todos:newTodos})
}
// 添加
addTodo=(todoObj)=>{
const {todos}=this.state
this.setState({todos:[todoObj,...todos]})
}
// 全选 or 全不选
checkAllTodo=(done)=>{
const {todos}=this.state
const newTodos=todos.map((i)=>{
@@ -49,6 +54,7 @@ class App extends React.Component {
})
this.setState({todos:newTodos})
}
// 清除已完成
clearAllDone=()=>{
const {todos}=this.state
const newTodos=todos.filter((i)=>{