版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/pansuyong/article/details/82758744
删除:handelItemDelete(index){
console.log("this666:",this);
// immutable 一成不变
// state 不允许我们做任何的改变
this.setState((prevState)=>{
const list =[...prevState.list];
list.splice(index,1);
return{
list
}
})
}
添加:
handleBtnClick(){
this.setState((prevState)=>({
list: [...prevState.list,prevState.inputValue],
inputValue:""
}),()=>{
console.log("999:",this.ul.querySelectorAll('div').length);
})
}