element-ui table 数据单选

426 阅读1分钟

小说明

  • 根据change事件修改model绑定的值
  • label绑定唯一值
  •  用来覆盖label的值,无需覆盖则不需要书写

template

<el-table-column label="选择">
    <template slot-scope="scope">
      <el-radio
        v-model="colonyId"
        :label="scope.row.serverId"
        @change="getSelectedId(scope.row.serverId)"
      >&nbsp;</el-radio>
    </template>
</el-table-column>

script

data(){
    return(){
    colonyId:''
    }
},
methods:{
    getSelectedId(id){
        this.colonyId = id;
    }
}