el-table点击表格行实现表格单选勾选

这篇博客探讨了如何在前端项目中使用Vue.js实现表格的数据绑定、单选操作及单元格样式定制。通过监听row-click事件,实现了表格行的选中与取消。同时,文章还展示了如何利用内联样式使单选框居中显示,确保UI的整洁。
摘要由CSDN通过智能技术生成
<div class="history-table">
 <el-table
   :data="tableData_history"
   highlight-current-row
   :cell-style="tableCellStyle"
   height="60vh"
   max-height="480"
   border
   @row-click="clickChange_history"
 >
<el-table-column class-name="allow" label="选择" width="50" align="center"><template slot-scope="scope"><el-radio v-model="tableRadio_history" :label="scope.row" @click.native="clickChange_history"><i /></el-radio></template></el-table-column>
data(){
	return{
	      tableRadio_history: [],
	}
}

 // 表格选中
 clickChange_history(row) {
   if (this.tableRadio_history === row) {
     this.tableRadio_history = []
   } else {
     this.tableRadio_history = row
   }
   this.single_history = this.tableRadio_history?.id?.length ? false : true
 },
<style lang="scss" scoped>
// 让单选框居中
.history-table{
  ::v-deep .el-table__body-wrapper{
    .el-radio__label {
      padding-left:0;
    }
  }
}
</style>
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值