antdvue selecet组件选项太多导致卡顿-解决办法之一

antdvue select组件选项太多时,首次选择非常卡顿,影响使用;

封装的select组件都默认打开了show-search属性

这里使用了@search方法

//定义搜索值
const selectKey = ref('')
//函数
function selectKeyChange(key) {
  selectKey.value = key
}
<Select
                      v-model:value="formData[item.labelName]"
                      :placeholder="item.placeholder"
                      show-search
                      :filter-option="filterOption"
                      option-filter-prop="titles"
                      size="middle"
                      :mode="item.mode || ''"
                      :disabled="item.readOnly || item.unedit || false"
                      :dropdown-menu-style="{ color: '#ff0000', background: '#ff0000' }"
                      :dropdown-match-select-width="false"
                      @select="selectChange(item, formData[item.labelName])"
                      @search="selectKeyChange"
                    >
                      <SelectOption
                        v-for="items in item.selectList.filter((ele) => {
                          if (item.selectList.length < 100){
                            return true;
                          }
                          else if (!selectKey)
                            return false;
                          return ele.title.includes(selectKey)
                        })"
                        :key="items.value"
                        :value="items.value"
                        :titles="items.title"
                        :disabled="items.disabled"
                      >
                        <span :titles="items.title">{{ items.label }}</span>
                      </SelectOption>
                    </Select>

1.默认100条以内不过滤选项;

2.如果搜索值selectKey为空,待选项为空

3.匹配了搜索值再出现选项

缺点:量大的时候默认无选项

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

tx10765

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

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

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

打赏作者

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

抵扣说明:

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

余额充值