el-table表格单选按钮

element-ui提供的表格组件是有单选功能的,只是组织形式是以选中行高亮的方式,有一些人会觉得不够明显,因此稍微变通一下,在每一行前加上radio单选按钮。

<el-table ref="ridioTable" :data="tableData" tooltip-effect="dark" height="255" style="width: 100%" @current-change="clickChange">
  <el-table-column label="选择" width="55">
    <template slot-scope="scope">
      <el-radio v-model="tableRadio" :label="scope.row"><i></i></el-radio>
    </template>
  </el-table-column>
   <el-table-column prop="code" label="编号" header-align="center" align="center"></el-table-column>
   <el-table-column prop="name" label="名称" header-align="center" align="center"></el-table-column>
</el-table>
clickChange (item) {
  this.tableRadio = item
}

实现的原理就是将当前选中行绑定到<el-radio>中。

"除了你,再也没有别人能给我一枝一叶的欣喜。"

猜你喜欢

转载自www.cnblogs.com/yanggb/p/12618463.html
今日推荐