如何选中及清除el-table选中项

2022-07-15 12:58:55

在这里插入图片描述

1.选中:

this.$refs.table.selection

2.清除:

  console.log(this.$refs.table.clearSelection());
<template><div><el-table
  v-if="tableData.length>0":data="tableData"
    style="width:100%":height="tableHeight"
     ref="table"><el-table-column
     type="index"></el-table-column><el-table-column
     type="selection"></el-table-column><el-table-column
      prop="date"
      label="日期"
      width="180"></el-table-column><el-table-column
      prop="name"
      label="姓名"
      width="180"></el-table-column><el-table-column
      prop="address"
      label="地址"></el-table-column></el-table><el-button @click="clearBtn">清除</el-button><el-button @click="select">获取选中项</el-button></div></template>clearBtn(){
        console.log(this.$refs.table.clearSelection());},select(){
        console.table(this.$refs.table.selection);}
  • 作者:_处女座程序员的日常
  • 原文链接:https://blog.csdn.net/qq_42931285/article/details/124855289
    更新时间:2022-07-15 12:58:55