element表格添加单选按钮

下面是主要代码,项目涉及隐私就不发全部代码了

1,首先在表格中添加如下代码,

:label="scope.$index + 1"不加的话不会显示出来
但是加了之后会出现数字 我用了css样式把数字隐藏了
/deep/ .el-radio__label{
  display: none;
}

 

 

 <el-table-column  label="选择" align="center" width="55">
          <template solt-scope="scope">
           <el-radio v-model="radio" :label="scope.$index + 1" @change.native="radioData(scope.row)"></el-radio>
          </template>
 </el-table-column>

2,在data中提供

radio: false // 单选按钮

3,在methods里提供方法,scope就是选中的数据

radioData (scope, row) {
      this.selectData = scope
    },

  

posted @ 2021-01-05 10:37  前端CodingPeasant  阅读(968)  评论(0编辑  收藏  举报