简体   繁体   English

关于复选框和单选按钮的问题

[英]Question about checkbox and radio buttons

I'm using element-ui and I have no idea how to make it work.我正在使用 element-ui,但我不知道如何使其工作。 I have the following code:我有以下代码:

<div v-for="(solution, s_index) in scope.row.arrayDefectiveActions"
:key="`${requirementTemplateTypeIndex}.${requirementExtendedItemIndex}.${s_index}`"
 style="display: inline-block;" class="p-sm">

<el-checkbox v-model="solution.checkActionTaken" 
:disabled="!scope.row.checkDefectiveItem" 
@change="articleChanged(requirementExtendedItem)">

</el-checkbox>
</div>

My question is how can I transform this checkbox into radio buttons, because I tried to use the exact same code but changed only the checkbox and I can select all of them without unchecking the others我的问题是如何将此复选框转换为单选按钮,因为我尝试使用完全相同的代码但只更改了复选框,并且我可以选择所有复选框而无需取消选中其他复选框

You must add :class="{'active':radio===item.id}" to the v-for iterator and use <el-radio v-model="radio" :label="item.id"> .您必须将:class="{'active':radio===item.id}"v-for迭代器并使用<el-radio v-model="radio" :label="item.id">

Here you can find a working example.在这里你可以找到一个工作示例。


Best regards,此致,

Brhaka布拉卡

Have a look to the documentation on how to use the proper component.查看有关如何使用正确组件的文档。

  • el-checkbox is for checkboxes el-checkbox用于复选框
  • el-radio for radios el-radio收音机

Documentation: https://element.eleme.cn/#/fr-FR/component/radio文档: https : //element.eleme.cn/#/fr-FR/component/radio

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM