vue element-ui el-table多选框多选删除实现

<div class="tbb">
<toolbar-button @click="add" :label="$t('common.add')" icon="el-icon-plus" size="small"></toolbar-button>
<toolbar-button @click="del" :label="$t('common.del')" icon="el-icon-plus" size="small"></toolbar-button>
</div>
<el-table ref="test" :data="testData" style='width:100%;height:100%;' border stripe="true" >
<el-table-column :label="$t('i18nSoftwareTrans.index')" type="index" width="80">
<template slot-scope="scope">
{{(scope.$index + 1)}}
</template>
</el-table-column>
<el-table-column type="selection" prop="rowid" ></el-table-column>
<el-table-column prop="name" label="名称" :show-overflow-tooltip="true" sortable>
</el-table-column>
</el-table>


testData:[{rowid:1,name:"1"},{rowid:2,name:"2"}],

add(){
let len = this.testData.length+1;
this.testData.push({rowid:len,name:`${len}`});
},
del(){
let len = this.testData.length;
for(let item in this.$refs.test.selection){
this.testData.splice(item.rowid - 1,1);
}
},
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值