el-tablel 组件实现 单选操作

项目中石油element-ui 的table组件实现单选的功能,需要用到单选按钮,实现效果:

 代码:

<el-table :data="tableDemand" ref="tableDemand" style="width: 98%;" class= "table-style" stripe>
                            <el-table-column width="50px" label="选择" align="center">
                                <template slot-scope="scope">
                                    <el-radio :label="scope.row.id" v-model="radio" @change.native="handleSelectionChange(scope.$index,scope.row)">&nbsp</el-radio>
                                </template>
                            </el-table-column>
                            <el-table-column prop="year" label="计划年度" align="center" min-width="30%"
                                             show-overflow-tooltip></el-table-column>
                            <el-table-column prop="regName" label="试剂类型" align="center" min-width="30%"
                                             show-overflow-tooltip></el-table-column>
                            <el-table-column prop="supplier" label="试剂厂商" align="center" min-width="30%"
                                             show-overflow-tooltip></el-table-column>
                            <el-table-column prop="batchNo" label="试剂批号" align="center" min-width="30%"
                                             show-overflow-tooltip></el-table-column>
                            <el-table-column prop="effectiveDate" label="试剂效期" align="center" min-width="30%"
                                             show-overflow-tooltip></el-table-column>
                            <el-table-column prop="numNow" label="调拨量" align="center" min-width="30%"
                                             show-overflow-tooltip></el-table-column>
                        </el-table>

主要的是:

<el-table-column width="50px" label="选择" align="center">
                                <template scope="scope">
                                    <el-radio :label="scope.row.id" v-model="radio" @change.native="handleSelectionChange(scope.$index,scope.row)">&nbsp</el-radio>
                                </template>
                            </el-table-column>

data: 

data(){
    return {
        radio:"",
        rowInfo:{},
    }
}

js:

handleSelectionChange(index,row) {
    this.rowInfo = row
},

因为label的原因,会在radio后面会出现id,如果把el-tadio中的label取消掉,单选会出现问题,所以添加了' &nbsp ' 以空格显示.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

开发那点事儿~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值