如何在elementUi 表格table组件内使用单选框radio
文章目录
解决思路:
使用elementUI的el-radio单选组件,通过插槽slot添加到表格内,通过table提供的单选方法row-click进行单选绑定。
简化实现例子:
<el-table
@row-click="getRowInfo"
>
<el-table-column width="50px" label="选择" align="center">
<template slot-scope="scope">
<el-radio v-model="radio" :label="scope.row.id"></el-radio>
</template>
</el-table>data(){
radio:"",
rowInfo:{},
}methods:{
getRowInfo(row){
this.radio= row.id;
this.rowInfo= row;
}
}// >>> 是深度选择器,一定要加上。否则不会覆盖elementUi的组件样式。
<style scoped>
>>> .el-radio {
margin-left: 6px;
}
>>> .el-radio .el-radio__label {
display: none;
}
</style>惟求热泪盈眶与成就感 ^_^
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论