ElementPlus 穿梭框支持批量穿梭

按照目前的方案试了**el-virtual-transfer**: ,这个库对于vue3+ts的代码无效。

方案:魔改原生的transfer组件,把原来的el-checkbox包一层虚拟滚动列表

废话不多说:实现的效果如下:

批量勾选3000个设备到左边做到不卡顿

关键代码:

复制代码
      <ElCheckboxGroup
        v-show="!hasNoMatch && data.length > 0"
        v-model="checked"
        :class="{ 'is-filterable': filterable }"
        class="el-transfer-panel__list"
        style="display: flex; flex-direction: column; height: 100%; overflow: hidden"
      >
        <VirtualList
          v-if="virtualScroll && filteredData.length > 0"
          style="flex: 1; height: 400px; overflow-y: auto"
          :data-key="propsAlias.key"
          :data-sources="filteredData"
          :data-component="TransferCheckboxItem"
          :estimate-size="40"
        />
        <template v-else>
          <ElCheckbox
            v-for="item in filteredData"
            :key="item[propsAlias.key]"
            :class="ns.be('panel', 'item')"
            :value="item[propsAlias.key]"
            :disabled="item[propsAlias.disabled]"
            :validate-event="false"
          >
            <OptionContent :option="optionRender?.(item)" />
          </ElCheckbox>
        </template>
      </ElCheckboxGroup>


import VirtualList from "vue3-virtual-scroll-list";

<customTransfer
        ref="transferRef"
        v-model="selectedDeviceKeys"
        :data="transferData"
        filterable
        :filter-method="filterMethod"
        filter-placeholder="请输入关键字进行模糊搜索"
        :titles="transferTitles"
        :button-texts="['解绑', '绑定']"
        class="full-height-transfer"
        :virtual-scroll="true"
/>

项目地址:https://github.com/EmilyHOC/el-transfer-pannel-bigData/tree/main

相关推荐
Aliex_git9 小时前
跨域请求笔记
前端·网络·笔记·学习
John_ToDebug9 小时前
引擎深处的漫游者:构建浏览器JavaScript引擎的哲学与技艺
javascript·chrome·js
37方寸10 小时前
前端基础知识(Node.js)
前端·node.js
程序猿阿伟10 小时前
《TypeScript中Protobuf到运行时类型安全的转换指南》
javascript·安全·typescript
powerfulhell10 小时前
寒假python作业5
java·前端·python
木子啊10 小时前
前端组件化:模板继承拯救发际线
前端
三十_A10 小时前
零基础通过 Vue 3 实现前端视频录制 —— 从原理到实战
前端·vue.js·音视频
前端小菜袅10 小时前
PC端原样显示移动端页面方案
开发语言·前端·javascript·postcss·px-to-viewport·移动端适配pc端
Highcharts.js10 小时前
如何使用Highcharts SVG渲染器?
开发语言·javascript·python·svg·highcharts·渲染器
We་ct10 小时前
LeetCode 228. 汇总区间:解题思路+代码详解
前端·算法·leetcode·typescript