
Research
/Security News
npm Author Qix Compromised via Phishing Email in Major Supply Chain Attack
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
@yeepay/custom-antdv-v1-lib
Advanced tools
一个基于 Ant Design Vue 1.7.8 和 Vue 2.6.14 的自定义组件库,提供高性能的虚拟滚动选择组件。
vue-virtual-scroller
实现高性能虚拟滚动npm install @yeepay/custom-antdv-lib vue-virtual-scroller
import Vue from 'vue';
import CustomAntdvLib from '@yeepay/custom-antdv-lib';
import 'ant-design-vue/dist/antd.css';
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css';
Vue.use(CustomAntdvLib);
import { VirtualSelect } from '@yeepay/custom-antdv-lib';
import 'ant-design-vue/dist/antd.css';
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css';
export default {
components: {
VirtualSelect
}
}
<template>
<div>
<!-- 基础选择框 -->
<VirtualSelect
:options="options"
v-model="selectedValue"
placeholder="请选择"
style="width: 200px"
/>
<!-- 自定义标签和值字段 -->
<VirtualSelect
:options="customOptions"
labelKey="name"
valueKey="id"
v-model="selectedId"
placeholder="请选择用户"
style="width: 250px"
/>
<!-- 启用搜索功能 -->
<VirtualSelect
:options="largeOptions"
:showSearch="true"
v-model="selectedValue"
placeholder="搜索并选择"
style="width: 300px"
/>
<!-- 自定义下拉列表高度 -->
<VirtualSelect
:options="options"
:virtualScrollHeight="400"
v-model="selectedValue"
placeholder="自定义高度"
style="width: 200px"
/>
</div>
</template>
<script>
export default {
data() {
return {
selectedValue: '',
selectedId: '',
options: [
{ key: '1', value: '选项 1' },
{ key: '2', value: '选项 2' },
{ key: '3', value: '选项 3' },
// ... 更多选项
],
customOptions: [
{ id: 1, name: '张三' },
{ id: 2, name: '李四' },
{ id: 3, name: '王五' },
],
largeOptions: Array.from({ length: 1000 }, (_, i) => ({
key: String(i + 1),
value: `选项 ${i + 1}`
}))
}
}
}
</script>
基于 Ant Design Vue 的 Select 组件封装,集成虚拟滚动功能,适用于大量数据的场景。
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
options | 选项数据数组 | Array | [] |
value | 当前选中的值 | String/Number/Array | '' |
disabled | 是否禁用 | Boolean | false |
placeholder | 占位符文本 | String | '请选择' |
labelKey | 选项标签字段名 | String | 'value' |
valueKey | 选项值字段名 | String | 'key' |
itemSize | 每个选项的高度(px) | Number | 36 |
showSearch | 是否启用搜索功能 | Boolean | false |
virtualScrollHeight | 虚拟滚动容器高度(px) | Number | 300 |
事件名 | 说明 | 回调参数 |
---|---|---|
input | 值变化时触发 | (value: String/Number/Array) |
change | 选择变化时触发 | (value: String/Number/Array) |
select | 选择选项时触发 | (item: Object) |
search | 搜索时触发 | (value: String) |
方法名 | 说明 | 参数 |
---|---|---|
focus | 获取焦点 | - |
blur | 失去焦点 | - |
支持所有 Ant Design Vue Select 组件的属性,包括但不限于:
size
- 选择框大小(large/default/small)loading
- 加载中状态allowClear
- 是否支持清除dropdownMatchSelectWidth
- 下拉菜单和选择器同宽getPopupContainer
- 菜单渲染父节点组件支持灵活的数据格式,通过 labelKey
和 valueKey
属性来指定字段映射:
// 默认格式
const options = [
{ key: '1', value: '选项 1' },
{ key: '2', value: '选项 2' }
];
// 自定义格式
const customOptions = [
{ id: 1, name: '张三' },
{ id: 2, name: '李四' }
];
// 使用自定义格式
<VirtualSelect
:options="customOptions"
labelKey="name"
valueKey="id"
/>
组件集成了 vue-virtual-scroller
,能够高效处理大量数据:
<VirtualSelect
:options="largeOptions"
:virtualScrollHeight="400" <!-- 设置容器高度 -->
:itemSize="36" <!-- 设置每个选项高度 -->
:showSearch="true" <!-- 启用搜索 -->
/>
启用搜索功能后,用户可以实时过滤选项:
<VirtualSelect
:options="options"
:showSearch="true"
@search="handleSearch"
/>
搜索功能特点:
组件支持完整的键盘导航功能:
npm install
npm run dev
npm run build
启动 Vue CLI 开发服务器进行组件调试:
npm run serve
这将在 http://localhost:8080
启动开发服务器,您可以在浏览器中查看和调试组件。
npm run test
npm run lint
custom-antdv-lib/
├── src/
│ ├── components/
│ │ └── CustomSelect.vue # 虚拟滚动选择组件
│ └── index.ts # 主入口文件
├── examples/ # Vue CLI 示例项目
├── dist/ # 构建输出目录
├── package.json
├── rollup.config.js
└── README.md
npm publish
MIT
FAQs
Custom Ant Design Vue component library
The npm package @yeepay/custom-antdv-v1-lib receives a total of 2 weekly downloads. As such, @yeepay/custom-antdv-v1-lib popularity was classified as not popular.
We found that @yeepay/custom-antdv-v1-lib demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.