下面是主要代碼,項目涉及隱私就不發全部代碼了
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 },