el-table实现跨页多选

<template>
  <div>
    <el-table
      :row-key="getRowKeys"
      @selection-change="handleChange"
      :data="displayedData"
      class="exporttable"
      style="width: 50%"
      border
    >
      <el-table-column :reserve-selection="true" type="selection"> </el-table-column>
      <el-table-column v-for="item in data1" :key="item" :prop="item" :label="item"> </el-table-column>
    </el-table>
    <el-pagination layout="prev, pager, next" @current-change="currentChange" :total="totalRows" :page-size="pageSize" />
  </div>
</template>
  data() {
    return {
      data: [
        {
          id: '1298712211',
          name: 'ddddd',
          amount1: '234',
          amount2: '3.2',
          amount3: 10,
        },
        {
          id: '12987122',
          name: 'Tom',
          amount1: '234',
          amount2: '3.2',
          amount3: 10,
        },
        {
          id: '12987123',
          name: 'Tom',
          amount1: '165',
          amount2: '4.43',
          amount3: 12,
        },
        {
          id: '12987124',
          name: 'jierui',
          amount1: '324',
          amount2: '1.9',
          amount3: 9,
        },
        {
          id: '12987125',
          name: 'Tom',
          amount1: '621',
          amount2: '2.2',
          amount3: 17,
        },
        {
          id: '12987126',
          name: 'Tom',
          amount1: '539',
          amount2: '4.1',
          amount3: 15,
        },
        {
          id: '12987127',
          name: 'Tom',
          amount1: '511139',
          amount2: '41.1',
          amount3: 15,
        },
        {
          id: '129871217',
          name: 'dddqqq',
          amount1: '511139',
          amount2: '41.1',
          amount3: 15,
        },
        {
          id: '129817127',
          name: 'dddqqq',
          amount1: '511139',
          amount2: '41.1',
          amount3: 15,
        },
      ],
      data1: ['name', 'amount1', 'amount2', 'amount3'],
      currentPage: 1,
      pageSize: 5 // Adjust this value based on your preference
    }
  },
  computed: {
    totalRows() {
      return this.data.length;
    },
    displayedData() {
      // Calculate the range of data to display based on current page and page size
      const startIndex = (this.currentPage - 1) * this.pageSize;
      const endIndex = startIndex + this.pageSize;
      return this.data.slice(startIndex, endIndex);
    },
  },
 methods: {
    currentChange(currentPage) {
      this.currentPage = currentPage;
    },
    handleChange(selection) {
      console.log(selection)
    },
    getRowKeys(row) {
      return row.id
    },
  },

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值