element的el-table 解决表格多页选择数据时,数据被清空

问题:切换页码时,勾选的数据会被清空 

 

 重点看我圈出来的,直接复制,注意,我这里  return row.productId;一般大家的是 return row.id,根据接口定的唯一变量

 :row-key="getRowKeys"​​​​​​​

 :reserve-selection="true"

  getRowKeys(row) {
        return row.productId;
      },

 官方解说

 

 

参考我项目里的下方代码 

 <el-table v-loading="listLoading"
              :data="list"
                ref="multipleTable"
              border
              fit
              @selection-change="handleSelectionChange"
            :row-key="getRowKeys"
              highlight-current-row>
      <el-table-column
      :reserve-selection="true"
        type="selection"
        width="40">
      </el-table-column>
      <el-table-column align="center"
                       width="180px"
                       label="销售单号">
        <template slot-scope="scope">
          <span>{{ scope.row.orderId }}</span>
        </template>
      </el-table-column>
    </el-table>


  data () {
    return {
  getRowKeys(row) {
        return row.productId;
      },
rowSelection:'',
    }


  methods: {
  handleSelectionChange(val) {
      this.rowSelection = val;
 
    },
}

 

最近更新

  1. TCP协议是安全的吗?

    2024-04-30 23:20:04       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-30 23:20:04       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-30 23:20:04       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-30 23:20:04       18 阅读

热门阅读

  1. 笔试强训-day14_T2 组队竞赛

    2024-04-30 23:20:04       12 阅读
  2. Git 最佳实践规范

    2024-04-30 23:20:04       10 阅读
  3. SQL中的top、limit以及rownum

    2024-04-30 23:20:04       12 阅读
  4. 二叉树oj题解1(最大深度,单值二叉树)

    2024-04-30 23:20:04       15 阅读
  5. 洛谷 P3865 【模板】ST 表

    2024-04-30 23:20:04       12 阅读
  6. C语言如何⽤指针表示字符串?

    2024-04-30 23:20:04       9 阅读
  7. SQL中为什么不要使用1=1?

    2024-04-30 23:20:04       8 阅读
  8. SpringMVC

    SpringMVC

    2024-04-30 23:20:04      9 阅读
  9. CentOS8系统Skywalking9监控MySQL8

    2024-04-30 23:20:04       10 阅读