VUE实现级联选择框与选项互斥

文章介绍了如何在Vue.js应用中实现级联选择功能,特别是如何根据一级选项查询并显示二级选项,以及确保二级选项的互斥性,即一旦一个二级选项被选中,其他地方不能再选中它。主要涉及的数据结构有questions、primaryIndicators、secondaryIndicatorkeys等,以及使用select和deselect事件来监听和控制选项状态。

需求

        功能布局如下图,实现根据一级选项的code去查询二级选项,并且其他二级选择框无法再次选中已经被选的二级选项。

代码实现

HTML

        一级选择框:
<div style="margin-top: 20px;" v-for="(item, index) in questions" :key="index">
                    <span><span style="color: red;">*</span>问题类别:</span>
                    <a-select style="width: 240px;"            :value="item.primaryIndicators.itemCode"
                        @change="handleChangetypes(index,$event)">
                        <a-select-option v-for="itemone,ccindex in problemTypeoptions" :key="itemone.itemCode+ccindex"
                            :value="itemone.itemCode">{
  
  { itemone.itemName }}
                        </a-select-option>
                    </a-select>
         二级选择框:
<a-select :showSearch="false" style="width: 240px;margin-left: 40px;" mode="multiple"
                        @change="handlechildtypes(index, item.secondaryIndicatorkeys)"
                        v-model:value="item.secondaryIndicatorkeys">
                        <a-select-op
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Leviash

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

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

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

打赏作者

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

抵扣说明:

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

余额充值