Element ui 点击分页时保存勾选框

<!-- table -->
    <el-table
      :data="tableData.slice((pagination.currentPage-1)*pagination.pageSize,pagination.currentPage*pagination.pageSize)"
      border
      @selection-change="handleSelectionChange"
      style="width: 100%"
      :row-key="getRowKeys"
    >
      <el-table-column type="selection" width="55" prop="id" :reserve-selection="true"></el-table-column>
      <el-table-column prop="centerId" label="区" width="180" align="center">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.centerId == 3" size="medium" type="primary">顺德</el-tag>
          <el-tag v-if="scope.row.centerId == 4" size="medium" type="danger">南海</el-tag>
          <el-tag v-if="scope.row.centerId == 5" size="medium" type="danger">禅城</el-tag>
          <el-tag v-if="scope.row.centerId == 6" size="medium" type="warning">三水</el-tag>
          <el-tag v-if="scope.row.centerId == 7" size="medium" type="info">高明</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="成本分类" width="180" align="center">区自选划小</el-table-column>
      <el-table-column prop="name" label="成本项目" width="180" align="center"></el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pagination.currentPage"
      :page-sizes="[5, 10, 20, 50]"
      :page-size="pagination.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="pagination.total"
    ></el-pagination>
    
    reserve-selection仅对 type=selection 的列有效,类型为 Boolean,为 true 则代表会保留之前数据的选项,需要配合 Table 的 clearSelection 方法使用
methods: {
    getRowKeys(row) {
      return row.Id
    },
    handleSelectionChange(arr){
      if(arr.length>0){
        this.multipleSelection = arr
      }
    }
}

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值