element中的el-table表格实现单选功能

项目场景:

element中的el-table表格有时候需要实现单选功能,效果如下:

在这里插入图片描述


实现方案:

<!-- 单选 -->
<el-table-column
  width="40">
   <template slot-scope="scope">
     <el-radio class="radio" :label="scope.row" v-model="radio" @change.native="getCurrentRow(scope.row)" >&nbsp;</el-radio>
  </template>
</el-table-column>
 data() {  
	return {
      radio: '',
	  policyData: {},
    };
  },
    getCurrentRow(val) {
      this.policyData = val;
    },

将选中行数据赋值给 this.policyData 进行后续的操作。


版权声明:本文为migexiaoliang原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。