加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

微信小程序踩坑记

发布时间:2020-12-14 19:42:38 所属栏目:资源 来源:网络整理
导读: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 })} 在删除数组元素时s

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)
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读