setData
TypeError: Cannot read property '__methodCaller' of undefined
remove(e){
let todoIndex = e.currentTarget.dataset.todoIndex
let todoList = this.data.todoList
todoList.splice(todoIndex,1)
this.setData({
todoList
})
}
在删除数组元素时setData会报错
TypeError: Cannot read property '__methodCaller' of undefined
解决办法 : 使用setTimeout
remove(e){
let todoIndex = e.currentTarget.dataset.todoIndex
let todoList = this.data.todoList
todoList.splice(todoIndex,1)
setTimeout(()=>{
this.setData({
todoList
})
},100)
}