elementUI type=“selection“多选框选中 删除 回显 赋值问题 回显数组改变选中状态未改变

业务需求:

点击查询弹列表框

勾选列表选项保存

可删除可重新查询列表添加

遇到的问题:删除之后查询列表selection回显问题

解决:@row-click配合:reserve-selection="true"使用

复制代码
      <el-table
        ref="refPlanTable"
        :data="refPlanTableData"
        tooltip-effect="dark"
        :max-height="400"
        :height="400"
        :header-cell-style="{textAlign: 'center'}"
        :cell-style="{textAlign:'center'}"
        @selection-change="handleSelectionChangeRef"
        @row-click="handleRowClickRef"
        :row-key="getRowKey"
      >
        <el-table-column type="selection" width="55" fixed="left" :reserve-selection="true"></el-table-column>
        </el-table>

handleRowClickRef(row){ this.$refs.refPlanTable.toggleRowSelection(row); },

表格data赋值的地方添加

注意::reserve-selection="true"会记录保存上一次选中的状态,所以每次赋值前要先清空选中状态

复制代码
          this.refPlanTableData=res.result;
          let string = this.multipleSelectionRef.map(item => item.identity);
          console.log(string);
          this.$nextTick(() => {
            this.refPlanTableData.forEach(item=>{
              this.$refs.refPlanTable&&this.$refs.refPlanTable.toggleRowSelection(item,false);
              if(string.includes(item.identity)){
                this.$refs.refPlanTable&&this.$refs.refPlanTable.toggleRowSelection(item,true);
              }
            })
          })
相关推荐
weixin-a153003083162 分钟前
【playwright篇】教程(十七)[html元素知识]
java·前端·html
ai小鬼头28 分钟前
AIStarter最新版怎么卸载AI项目?一键删除操作指南(附路径设置技巧)
前端·后端·github
wen's35 分钟前
React Native 0.79.4 中 [RCTView setColor:] 崩溃问题完整解决方案
javascript·react native·react.js
一只叫煤球的猫1 小时前
普通程序员,从开发到管理岗,为什么我越升职越痛苦?
前端·后端·全栈
vvilkim1 小时前
Electron 自动更新机制详解:实现无缝应用升级
前端·javascript·electron
vvilkim1 小时前
Electron 应用中的内容安全策略 (CSP) 全面指南
前端·javascript·electron
aha-凯心1 小时前
vben 之 axios 封装
前端·javascript·学习
漫谈网络2 小时前
WebSocket 在前后端的完整使用流程
javascript·python·websocket
遗憾随她而去.2 小时前
uniapp 中使用路由导航守卫,进行登录鉴权
前端·uni-app
xjt_09012 小时前
浅析Web存储系统
前端