el-table数据回显?

问题描述

项目中遇到一个el-table回显勾选的问题

问题出现的环境背景及自己尝试过哪些方法

vue2 + element-ui

相关代码

回显时使用的方法

echoData(){
  this.opeartionList.forEach(item=>{
    this.$nextTick(() => {
      if (this.form.cNameList.includes(item.id)) {
        this.$refs.tabOpRefOpear && this.$refs.tabOpRefOpear.toggleRowSelection(item);
      }
    });
  })
},

你期待的结果是什么?实际看到的错误信息又是什么?

回显不生效,没有报错,应该是这个方法有问题

阅读 2.1k
1 个回答

结合描述与代码来看,推测问题可能出在echoData方法调用的时机上以及nextTick写在了循环内.

echoData(){
  this.$nextTick(() => {
    this.opeartionList.forEach(item => {
      if (this.form.cNameList.includes(item.id)) {
        this.$refs.tabOpRefOpear && this.$refs.tabOpRefOpear.toggleRowSelection(item);
      }
    })
  })
}

确保你在处理回显时已经拿到cNameList数据及opeartionList数据.建议async & await 处理请求.

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题