first commit
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
## 1.0.62(2025-11-23)
|
||||
优化
|
||||
## 1.0.61(2025-11-23)
|
||||
优化禁用逻辑
|
||||
## 1.0.60(2025-11-23)
|
||||
优化功能
|
||||
## 1.0.59(2025-09-11)
|
||||
添加手动弹窗方向,direction:up、down,不传或者传其他值默认自动判断方向
|
||||
## 1.0.58(2025-07-14)
|
||||
优化兼容性
|
||||
## 1.0.57(2025-07-14)
|
||||
兼容vue2小程序
|
||||
## 1.0.56(2025-05-13)
|
||||
提取公共方法,功能未变
|
||||
## 1.0.55(2025-03-27)
|
||||
初始默认列表报错bug修复
|
||||
## 1.0.54(2024-12-23)
|
||||
修改bug
|
||||
## 1.0.53(2024-12-23)
|
||||
修改bug
|
||||
## 1.0.52(2024-12-18)
|
||||
优化
|
||||
## 1.0.49(2024-12-01)
|
||||
修复bug
|
||||
## 1.0.48(2024-12-01)
|
||||
添加搜索防抖
|
||||
## 1.0.47(2024-09-02)
|
||||
修改bug
|
||||
## 1.0.46(2024-09-02)
|
||||
初始化数据
|
||||
## 1.0.45(2024-08-09)
|
||||
添加vue2支持
|
||||
## 1.0.43(2024-07-28)
|
||||
删除边框阴影
|
||||
## 1.0.42(2024-05-18)
|
||||
删除注释
|
||||
## 1.0.41(2024-05-18)
|
||||
删除无用代码
|
||||
## 1.0.40(2024-05-18)
|
||||
修改bug
|
||||
## 1.0.39(2024-05-11)
|
||||
删掉多余代码
|
||||
## 1.0.38(2024-05-10)
|
||||
删除log
|
||||
## 1.0.37(2024-05-10)
|
||||
修改回显bug
|
||||
## 1.0.36(2024-05-09)
|
||||
修改默认值问题
|
||||
## 1.0.35(2024-05-09)
|
||||
修改回显bug
|
||||
## 1.0.34(2024-05-09)
|
||||
修复默认值问题
|
||||
## 1.0.33(2024-05-01)
|
||||
添加开启虚拟列表配置virtualList,大数据渲染
|
||||
## 1.0.32(2024-04-27)
|
||||
添加是否显示省略号配置,添加选项自定义插槽option,具体看示例代码
|
||||
## 1.0.31(2024-04-27)
|
||||
优化微信小程序显示问题
|
||||
## 1.0.30(2024-04-27)
|
||||
优化代码
|
||||
## 1.0.29(2024-04-26)
|
||||
修改截图
|
||||
## 1.0.28(2024-04-26)
|
||||
修改禁用颜色
|
||||
## 1.0.27(2024-04-26)
|
||||
添加多选模式,选择项的折叠配置
|
||||
## 1.0.26(2024-04-26)
|
||||
添加禁用选择配置,设置边框,单选模式设置选择框高度
|
||||
## 1.0.25(2024-04-24)
|
||||
添加git地址
|
||||
## 1.0.24(2024-04-24)
|
||||
修复单选模式,回显数据匹配不到报错的问题,@qidaichongfe**outlook.com 感谢这位朋友
|
||||
## 1.0.23(2024-04-19)
|
||||
清空bug修复
|
||||
## 1.0.22(2024-04-08)
|
||||
修复滚动条问题
|
||||
## 1.0.21(2024-04-08)
|
||||
修复bug
|
||||
## 1.0.20(2024-04-08)
|
||||
修复默认宽度问题
|
||||
## 1.0.19(2024-04-07)
|
||||
添加文档说明,修复过滤输入框点击多次滚动的问题
|
||||
## 1.0.18(2024-04-06)
|
||||
添加change事件返回数据的格式配置,changeType:"objectValue",表示返回完整对象,具体看示例代码,修复单选数据为空报错问题,
|
||||
## 1.0.17(2024-03-31)
|
||||
添加自动判断弹出位置,若底部空白不足,会自动切换为顶部弹出下拉选项,防止遮挡
|
||||
## 1.0.16(2024-03-31)
|
||||
修改demo注释
|
||||
## 1.0.15(2024-03-31)
|
||||
修改注释
|
||||
## 1.0.14(2024-03-30)
|
||||
修改为动态获取元素的高度,添加回显滚动动画
|
||||
## 1.0.13(2024-03-30)
|
||||
修改文档
|
||||
## 1.0.12(2024-03-30)
|
||||
修改文档
|
||||
## 1.0.11(2024-03-30)
|
||||
修改文档
|
||||
## 1.0.10(2024-03-30)
|
||||
修改布局
|
||||
## 1.0.9(2024-03-30)
|
||||
更换图标
|
||||
## 1.0.8(2024-03-30)
|
||||
添加多选功能,长文本显示省略号
|
||||
## 1.0.7(2024-03-30)
|
||||
添加选项是否禁用属性
|
||||
## 1.0.6(2024-03-29)
|
||||
更新文档
|
||||
## 1.0.5(2024-03-29)
|
||||
更新文档
|
||||
## 1.0.4(2024-03-29)
|
||||
更新文档
|
||||
## 1.0.3(2024-03-29)
|
||||
更新使用文档
|
||||
## 1.0.2(2024-03-29)
|
||||
修改说明文档
|
||||
## 1.0.1(2024-03-29)
|
||||
添加示例代码
|
||||
## 1.0.0(2024-03-29)
|
||||
数据下拉 选择框,支持单选,关键词筛选,
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,106 @@
|
||||
export default {
|
||||
// 数据列表
|
||||
options: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
// #ifndef VUE3
|
||||
// v-model值 vue2
|
||||
value: {
|
||||
type: [String, Number, Array],
|
||||
default: "",
|
||||
},
|
||||
// #endif
|
||||
// #ifdef VUE3
|
||||
// v-model值 (Vue3)
|
||||
modelValue: {
|
||||
type: [String, Number, Array],
|
||||
default: "",
|
||||
},
|
||||
// #endif
|
||||
// 是否可过滤
|
||||
filterable: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
// 占位符
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: "请选择"
|
||||
},
|
||||
// 过滤输入框占位符;为空时沿用 placeholder
|
||||
filterPlaceholder: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
// 是否可清空
|
||||
clearable: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
// 是否多选
|
||||
multiple: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
// 是否禁用
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
// 是否显示选中值 up, down
|
||||
direction: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
// 显示文本的键名
|
||||
labelKey: {
|
||||
type: String,
|
||||
default: "label"
|
||||
},
|
||||
// 值的键名
|
||||
valueKey: {
|
||||
type: String,
|
||||
default: "value"
|
||||
},
|
||||
// 空数据文本
|
||||
emptyText: {
|
||||
type: String,
|
||||
default: "No Data"
|
||||
},
|
||||
// change事件返回类型
|
||||
changeType: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
// 是否开启虚拟列表
|
||||
virtualList: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
// 边框样式
|
||||
border: {
|
||||
type: String,
|
||||
default: "1px solid #e5e5e5"
|
||||
},
|
||||
// 高度
|
||||
height: {
|
||||
type: String,
|
||||
default: "35px"
|
||||
},
|
||||
// 是否显示省略号
|
||||
showEllipsis: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
// 是否折叠选项
|
||||
collapseTags: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
// 折叠数量
|
||||
collapseTagsNum: {
|
||||
type: Number,
|
||||
default: 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* 防抖函数
|
||||
* @param {Function} fn 需要防抖的函数
|
||||
* @param {Number} delay 延迟时间
|
||||
*/
|
||||
export const debounce = (fn, delay) => {
|
||||
let timer = null;
|
||||
return function(...args) {
|
||||
if (timer) clearTimeout(timer);
|
||||
timer = setTimeout(() => fn.apply(this, args), delay);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* 节流函数
|
||||
* @param {Function} fn 需要节流的函数
|
||||
* @param {Number} wait 等待时间
|
||||
*/
|
||||
export const throttle = (fn, wait) => {
|
||||
let timer = null;
|
||||
return function(...args) {
|
||||
if (!timer) {
|
||||
timer = setTimeout(() => {
|
||||
fn.apply(this, args);
|
||||
timer = null;
|
||||
}, wait);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* 数据处理函数
|
||||
* @param {Array} options 数据源
|
||||
* @param {String} valueKey 值键名
|
||||
* @param {String} labelKey 标签键名
|
||||
*/
|
||||
export const formatOptions = (options, valueKey, labelKey) => {
|
||||
return options.map(item => ({
|
||||
...item,
|
||||
value: item[valueKey],
|
||||
label: item[labelKey]
|
||||
}));
|
||||
};
|
||||
|
||||
/**
|
||||
* 搜索过滤
|
||||
* @param {Array} data 数据源
|
||||
* @param {String} searchText 搜索文本
|
||||
* @param {String} labelKey 标签键名
|
||||
*/
|
||||
export const filterData = (data, searchText, labelKey) => {
|
||||
const loweredText = searchText.toLowerCase();
|
||||
return data.filter(item => {
|
||||
const label = String(item[labelKey]).toLowerCase();
|
||||
return label.includes(loweredText);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 计算虚拟列表可视区域数据
|
||||
* @param {Array} data 数据源
|
||||
* @param {Number} start 起始索引
|
||||
* @param {Number} pageSize 每页数量
|
||||
*/
|
||||
export const getVisibleData = (data, start, pageSize) => {
|
||||
const end = Math.min(start + pageSize, data.length); // 限制结束索引不超过数据长度
|
||||
return data.slice(start, end);
|
||||
};
|
||||
@@ -0,0 +1,99 @@
|
||||
{
|
||||
"id": "lu-data-select",
|
||||
"displayName": "lu-data-select",
|
||||
"version": "1.0.62",
|
||||
"description": "lu-data-select,数据,下拉菜单,下拉选择组件(单选、多选),返回值配置,自定义插槽",
|
||||
"keywords": [
|
||||
"lu-data-select"
|
||||
],
|
||||
"repository": "https://gitee.com/lu-my/lu-data-select.git",
|
||||
"engines": {
|
||||
"HBuilderX": "^3.96",
|
||||
"uni-app": "^4.07",
|
||||
"uni-app-x": ""
|
||||
},
|
||||
"dcloudext": {
|
||||
"type": "component-vue",
|
||||
"sale": {
|
||||
"regular": {
|
||||
"price": "0.00"
|
||||
},
|
||||
"sourcecode": {
|
||||
"price": "0.00"
|
||||
}
|
||||
},
|
||||
"contact": {
|
||||
"qq": ""
|
||||
},
|
||||
"declaration": {
|
||||
"ads": "无",
|
||||
"data": "无",
|
||||
"permissions": "无"
|
||||
},
|
||||
"npmurl": "",
|
||||
"darkmode": "x",
|
||||
"i18n": "x",
|
||||
"widescreen": "x"
|
||||
},
|
||||
"uni_modules": {
|
||||
"dependencies": [],
|
||||
"encrypt": [],
|
||||
"platforms": {
|
||||
"cloud": {
|
||||
"tcb": "x",
|
||||
"aliyun": "x",
|
||||
"alipay": "x"
|
||||
},
|
||||
"client": {
|
||||
"uni-app": {
|
||||
"vue": {
|
||||
"vue2": {
|
||||
},
|
||||
"vue3": {
|
||||
}
|
||||
},
|
||||
"web": {
|
||||
"safari": "√",
|
||||
"chrome": "√"
|
||||
},
|
||||
"app": {
|
||||
"vue": "√",
|
||||
"nvue": "-",
|
||||
"android": "√",
|
||||
"ios": "-",
|
||||
"harmony": "-"
|
||||
},
|
||||
"mp": {
|
||||
"weixin": "√",
|
||||
"alipay": "-",
|
||||
"toutiao": "-",
|
||||
"baidu": "-",
|
||||
"kuaishou": "-",
|
||||
"jd": "-",
|
||||
"harmony": "-",
|
||||
"qq": "-",
|
||||
"lark": "-"
|
||||
},
|
||||
"quickapp": {
|
||||
"huawei": "-",
|
||||
"union": "-"
|
||||
}
|
||||
},
|
||||
"uni-app-x": {
|
||||
"web": {
|
||||
"safari": "-",
|
||||
"chrome": "-"
|
||||
},
|
||||
"app": {
|
||||
"android": "-",
|
||||
"ios": "-",
|
||||
"harmony": "-"
|
||||
},
|
||||
"mp": {
|
||||
"weixin": "-"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
# lu-data-select
|
||||
|
||||
# 数据下拉选择组件
|
||||
|
||||
单选、多选,关键词过滤,清空,空数据插槽,标题过长显示省略号
|
||||
|
||||
数据列表较多时,选中再次打开,选中的数据项,自动滚动到可视区域
|
||||
|
||||
# 示例代码
|
||||
|
||||
```javascript
|
||||
|
||||
<template>
|
||||
<view class="content">
|
||||
<view class="title">1.单选,过滤</view>
|
||||
<lu-data-select placeholder="请选择数据" :options="selectData" v-model="condition1" :multiple="false" :filterable="true" @change="onchange"></lu-data-select>
|
||||
|
||||
<view class="title">2.单选,过滤,change返回对象格式</view>
|
||||
<lu-data-select placeholder="请选择数据" :options="selectData" v-model="condition1" filterable changeType="objectValue" @change="onchange"></lu-data-select>
|
||||
|
||||
<view class="title">3.多选,过滤</view>
|
||||
<lu-data-select placeholder="请选择数据" :options="selectData" v-model="condition" :filterable="true" :multiple="true" @change="onchange"></lu-data-select>
|
||||
|
||||
<view class="title">4.多选,过滤,change返回对象格式</view>
|
||||
<lu-data-select
|
||||
disabled
|
||||
placeholder="请选择数据"
|
||||
:options="selectData"
|
||||
v-model="condition"
|
||||
:filterable="true"
|
||||
:multiple="true"
|
||||
changeType="objectValue"
|
||||
@change="onchange"
|
||||
></lu-data-select>
|
||||
|
||||
<view class="title">5.自定义空数据插槽</view>
|
||||
<lu-data-select placeholder="请选择数据" :options="selectData1" v-model="condition" :multiple="true" :clearable="true" :filterable="true" @change="onchange">
|
||||
<template #empty>
|
||||
<view style="text-align: center; padding: 20rpx; color: #f00">空数据插槽</view>
|
||||
</template>
|
||||
</lu-data-select>
|
||||
<view class="title">6.自动判断弹出方向,演示,无需配置</view>
|
||||
<lu-data-select placeholder="请选择数据" :options="selectData" v-model="condition" :multiple="true" :clearable="true" :filterable="true" @change="onchange">
|
||||
<template #empty>
|
||||
<view style="text-align: center; padding: 20rpx; color: #f00">空数据插槽</view>
|
||||
</template>
|
||||
</lu-data-select>
|
||||
|
||||
<view class="title">7.边框,css的border属性,单选模式选择框高度height,多选默认自动增高</view>
|
||||
<lu-data-select
|
||||
placeholder="请选择数据"
|
||||
:options="selectData"
|
||||
v-model="condition1"
|
||||
:multiple="false"
|
||||
:filterable="true"
|
||||
height="100rpx"
|
||||
border="1px solid #f00"
|
||||
@change="onchange"
|
||||
></lu-data-select>
|
||||
|
||||
<view class="title">8.禁用选择</view>
|
||||
<lu-data-select placeholder="请选择数据" disabled :options="selectData" v-model="condition1"></lu-data-select>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
const condition1 = ref('8');
|
||||
const condition2 = ref('8');
|
||||
const condition = ref(['7']); //多选必须是数组格式
|
||||
|
||||
const selectData1 = ref([]);
|
||||
const selectData = ref([
|
||||
{
|
||||
value: '1',
|
||||
label: '测试标题测试标题测试标题测试标题测试标题测试标题测试标题1'
|
||||
},
|
||||
{
|
||||
value: '2',
|
||||
label: '数据2',
|
||||
disabled: true
|
||||
},
|
||||
{
|
||||
value: '3',
|
||||
label: '数据3',
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
value: '4',
|
||||
label: '数据4',
|
||||
disabled: true
|
||||
},
|
||||
{
|
||||
value: '5',
|
||||
label: '数据5'
|
||||
},
|
||||
{
|
||||
value: '6',
|
||||
label: '数据6'
|
||||
},
|
||||
{
|
||||
value: '7',
|
||||
label: '数据7'
|
||||
},
|
||||
{
|
||||
value: '8',
|
||||
label: '数据8'
|
||||
},
|
||||
{
|
||||
value: '9',
|
||||
label: '数据9'
|
||||
},
|
||||
{
|
||||
value: '10',
|
||||
label: '数据10'
|
||||
},
|
||||
{
|
||||
value: '11',
|
||||
label: '数据数据数据数据数据数据数据数据数据数据数据数据数据11'
|
||||
},
|
||||
{
|
||||
value: '12',
|
||||
label: '数据12'
|
||||
},
|
||||
{
|
||||
value: '13',
|
||||
label: '数据列表13'
|
||||
}
|
||||
]);
|
||||
const onchange = (e) => {
|
||||
console.log(e);
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.content {
|
||||
padding: 20px;
|
||||
|
||||
.title {
|
||||
padding: 10px 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
```
|
||||
|
||||
# 参数
|
||||
|
||||
| 参数名称 | 类型 | 默认值 | 可选值 | 说明 |
|
||||
| ----------- | ------- | ------ | ------------ | ----------------------------- |
|
||||
| v-model | String | | | 选中项绑定的值 |
|
||||
| options | Array | [ ] | | 数据列表,见下方 options 参数 |
|
||||
| labelKey | String | label | | 作为 label 唯一标识的键名 |
|
||||
| valueKey | String | value | | 作为 value 唯一标识的键名 |
|
||||
| multiple | Boolean | false | true / false | 是否多选 |
|
||||
| direction | String | "" | down / up | 弹出方向,up、down, 其他值无效,自动判断方向 |
|
||||
| filterable | Boolean | true | true / false | 是否可以筛选 |
|
||||
| clearable | Boolean | true | true / false | 是否可以清空 |
|
||||
| placeholder | String | 请选择 | | 默认提示语 |
|
||||
| disabled | Boolean | false | true / false| 是否禁用选择 |
|
||||
| border | String | '1px solid #e5e5e5' | css属性值 | 边框设置 |
|
||||
| showEllipsis | Boolean | true | true / false | 选项过长是否显示省略号 |
|
||||
| height | String | '35px' | css属性值 | 选择框高度,单选模式有效 |
|
||||
| collapseTags | Boolean | false | true / false | 是否折叠 |
|
||||
| collapseTagsNum | Number | 1 | | 多少开始折叠 |
|
||||
| virtualList | Boolean | false | true / false | 大数据开启虚拟列表 |
|
||||
| emptyText | String | 无数据 | | options 为空的时候显示的文本 |
|
||||
| changeType | String | " ",可以不传,默认是返回value | "objectValue" | change事件返回的数据格式,默认:单选返回value值,多选返回value组成的数组,objectValue:单选返回对象,多选返回数组对象 |
|
||||
|
||||
# options 参数
|
||||
|
||||
| 名称 | 类型 | 说明 |
|
||||
| -------- | --------------- | -------------- |
|
||||
| label | String / Number | 选项的标签 |
|
||||
| value | String / Number | 选项的值 |
|
||||
| disabled | Boolean | 是否禁用该选项 |
|
||||
|
||||
# 事件
|
||||
|
||||
| 事件 | 说明 |
|
||||
| ------ | ------------------ |
|
||||
| change | 选项发生改变时触发 |
|
||||
|
||||
# 插槽
|
||||
|
||||
| 名称 | 说明 |
|
||||
| ----- | ---------------- |
|
||||
| empty | 自定义无数据内容 |
|
||||
| option| 自定义选项插槽,返回值row:当前选项,$index:当前选项数组下标 |
|
||||
Reference in New Issue
Block a user