element的el-table表格复选框只能选中一条,选择下一条,上一条去掉勾选。使用文档中select方法,el-table绑定一个ref。具体代码实现如下

<el-table :data="childList" border height="100%" size="mini"
           ref="multipleTable"  @select="select">
     <el-table-column  type="selection" width="55"></el-table-column>
     <el-table-column type="index" width="55" label="序号"></el-table-column>
     <el-table-column prop="pay_method" label="支付方式"  :show-overflow-tooltip="true"></el-table-column>
     <el-table-column prop="pay_account_no" label="付款方账号"  :show-overflow-tooltip="true"></el-table-column>
     <el-table-column prop="recv_account_no" label="收款方账号" :show-overflow-tooltip="true"></el-table-column>
     <el-table-column prop="amount" label="金额" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="summary" label="摘要" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="reference" label="备注" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="trade_date" label="交易时间" :show-overflow-tooltip="true"></el-table-column>
</el-table>


data(){
     return {
        bill_id:""
    }
},
method:{
    select(selection, row){
         this.bill_id = row.id;
         // 清除 所有勾选项
         this.$refs.multipleTable.clearSelection()
         // 当表格数据都没有被勾选的时候 就返回
         // 主要用于将当前勾选的表格状态清除
         if(selection.length == 0) return 
         this.$refs.multipleTable.toggleRowSelection(row, true);
    },
}

toggleRowSelection:用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中) 

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐