this.$refs.multipleTable.toggleRowSelection 获取子组件的refs来操作

在不好用或者获取不到的时候就要使用

this.$nextTick(() => {
          this.enterpriseIds.forEach((row) => {
            this.$refs.multipleTable.toggleRowSelection(row, true)
          })
        })

 如果你在el-dialog里写了表格多选 那么你一定要在el-table行内加上:row-key="handleRowKeyEvent" 然后选择一个来当key 例如:

handleRowKeyEvent(row) {
      return row.id
    },
如果你不设置这个的话 上面那个this.$refs.multipleTable.toggleRowSelection(this.enterpriseIds)指定行选择就找不到
如果你想关闭弹窗取消的时候不保存数据,那么你就要在关闭弹窗的时候清空选择
this.$nextTick(() => {
        this.$refs.multipleTable.clearSelection()
      })
然后再点击的时候用this.$refs.multipleTable.toggleRowSelection(this.enterpriseIds)默认选择上你想要的选项
 

 

posted @ 2024-08-14 09:50  prince11  阅读(1)  评论(0编辑  收藏  举报