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>

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM