<el-table
ref="multipleTable"
:data="tableData"
:header-cell-style="{background:'#F8F8F9'}"
style="width: 100%;margin-top: 20px">
<el-table-column label="选择" align="center" width="65">
<template scope="scope">
<el-radio :label="scope.$index" v-model="radio"
@change.native="getCurrentRow(scope.row)"></el-radio>
</template>
</el-table-column>
<el-table-column align="center" label="编号" width="160" prop="studentCode"></el-table-column>
<el-table-column align="center" prop="name" label="姓名" width="120"></el-table-column>
<el-table-column align="center" prop="phone" label="账号"></el-table-column>
</el-table>
在使用el-radio标签的时候,需要绑定label的值,这里label我绑定的是index,有时候在单选位置是不需要将label的值显示出来,这个时候只需要在el-radio标签里面加上'  ;'即可。
<el-radio :label="scope.$index"
v-model="radio"
@change.native="getCurrentRow(scope.row)"> </el-radio>
js代码实现如下:
data: {
return() {
templateSelection: {},
radio: '',
tableData: []
}
}
methods: {
getCurrentRow(row){
// 获取选中数据 row表示选中这一行的数据,可以从里面提取所需要的值
this.templateSelection = row
}
}