ElementUI table 中的单选按钮

常见的组件中都是复选框,如果把复选框改为单选按钮,详细如下:

代码

<el-table :data="gatewayTableData " border class="table"
ref="gatewayTable" style="margin-top: 10px"
height="360" v-loading="loadingShow"
@current-change="updateCurrentGateway"
highlight-current-row
>

<el-table-column label="" width="35" align="center">
    <template slot-scope="scope">
<el-radio :label="scope.row.id32" v-model="radio"
@change.native="getCurrentGateway(scope.row)"
style="color: #fff;"></el-radio>
</template>
</el-table-column>
<el-table-column prop="index" label="序号" width="55">
<template slot-scope="scope">
<span>{{scope.$index +1}}</span>
</template>
</el-table-column>
</el-table>

<script>
  export default(){
    data:return{
      radio:'',//关联的单选按钮
    },
    methods:{
      //单选选中
      getCurrentGateway(row){
      this.gatewaySelectData = row;
      },
      //点击选中的行也可以选中单选按钮
      updateCurrentGateway(row){
     //如果没有row,终止
    if(!row) return;
    //把当前行label绑定的值和v-model绑定的值相同时,单选按钮就可以选中
     this.radio = row.id32;
    this.gatewaySelectData = row;
   } 
  }
<script>

 

 

 
posted @   三寸日光  阅读(2382)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
点击右上角即可分享
微信分享提示