@ebfe/vantkit-doc 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.d.ts +7 -0
- package/es/index.js +3 -7
- package/lib/@ebfe/vant-kit.cjs.js +20 -0
- package/lib/@ebfe/vant-kit.es.js +16 -0
- package/lib/@ebfe/vant-kit.js +29 -0
- package/lib/@ebfe/vant-kit.min.js +20 -0
- package/lib/index.css +0 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +28 -7
- package/lib/web-types.json +284 -0
- package/package.json +2 -2
- package/es/coloring-avatar/README.md +0 -110
- package/es/date-picker/README.md +0 -248
- package/es/date-range-picker/README.md +0 -369
- package/es/field-date-picker/README.md +0 -101
- package/es/field-date-range-picker/README.md +0 -134
- package/es/field-mask-txt/README.md +0 -281
- package/es/field-multi-picker/README.md +0 -115
- package/es/field-single-picker/README.md +0 -107
- package/es/mask-txt/README.md +0 -214
- package/es/multi-picker/README.md +0 -183
- package/es/single-picker/README.md +0 -239
- package/lib/coloring-avatar/README.md +0 -110
- package/lib/date-picker/README.md +0 -248
- package/lib/date-range-picker/README.md +0 -369
- package/lib/field-date-picker/README.md +0 -101
- package/lib/field-date-range-picker/README.md +0 -134
- package/lib/field-mask-txt/README.md +0 -281
- package/lib/field-multi-picker/README.md +0 -115
- package/lib/field-single-picker/README.md +0 -107
- package/lib/mask-txt/README.md +0 -214
- package/lib/multi-picker/README.md +0 -183
- package/lib/single-picker/README.md +0 -239
package/es/date-picker/README.md
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
# DatePicker
|
|
2
|
-
|
|
3
|
-
### 介绍
|
|
4
|
-
|
|
5
|
-
主要基于 vant 的 popup、date-picker 组件进行二次封装,方便处理时间选择的需求场景。
|
|
6
|
-
|
|
7
|
-
- 支持传入所有 [date-picker props](https://vant-ui.github.io/vant/#/zh-CN/date-picker#props)
|
|
8
|
-
- 支持暴露所有 [date-picker slots](https://vant-ui.github.io/vant/#/zh-CN/date-picker#slots)
|
|
9
|
-
|
|
10
|
-
**主要功能描述**
|
|
11
|
-
|
|
12
|
-
- 支持自定义触发器
|
|
13
|
-
- 支持自定义展示值
|
|
14
|
-
- 支持更改 picker 打开时默认选中的值(modelValue 有值,则以modelValue 为准)
|
|
15
|
-
|
|
16
|
-
**对开发者的解脱**
|
|
17
|
-
|
|
18
|
-
- 符合 ui 设计
|
|
19
|
-
- 默认处理选项的 formatter
|
|
20
|
-
- 打开收起逻辑的编写
|
|
21
|
-
- 对所选项 `真实值`、`展示值` 的隔离和处理
|
|
22
|
-
|
|
23
|
-
## 代码演示
|
|
24
|
-
|
|
25
|
-
### 基础用法
|
|
26
|
-
|
|
27
|
-
```html
|
|
28
|
-
<template>
|
|
29
|
-
<DatePicker v-model="modelValue" :picker-props="{ title: '基础用法' }">
|
|
30
|
-
<template #trigger="{ triggerPopupShow, showValue }">
|
|
31
|
-
<div class="trigger-box">
|
|
32
|
-
<p>value:{{ modelValue }}</p>
|
|
33
|
-
<p>showValue:{{ showValue }}</p>
|
|
34
|
-
<van-button @click="triggerPopupShow"> trigger </van-button>
|
|
35
|
-
</div>
|
|
36
|
-
</template>
|
|
37
|
-
</DatePicker>
|
|
38
|
-
</template>
|
|
39
|
-
|
|
40
|
-
<script setup lang="ts">
|
|
41
|
-
import { useWrapperRef } from '@ebfe/vhooks';
|
|
42
|
-
import { DatePicker } from '@ebfe/vant-kit';
|
|
43
|
-
import { Button as VanButton } from 'vant';
|
|
44
|
-
|
|
45
|
-
const [modelValue] = useWrapperRef('');
|
|
46
|
-
</script>
|
|
47
|
-
|
|
48
|
-
<style scoped lang="less">
|
|
49
|
-
.trigger-box {
|
|
50
|
-
display: flex;
|
|
51
|
-
flex-direction: column;
|
|
52
|
-
justify-content: center;
|
|
53
|
-
align-items: center;
|
|
54
|
-
}
|
|
55
|
-
</style>
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### 格式化展示值
|
|
59
|
-
|
|
60
|
-
```html
|
|
61
|
-
<template>
|
|
62
|
-
<DatePicker
|
|
63
|
-
v-model="modelValue"
|
|
64
|
-
:show-value-formatter="(date) => dayjs(date).format('YY年MM月DD日')"
|
|
65
|
-
:picker-props="{ title: '格式化展示值' }"
|
|
66
|
-
@confirm="
|
|
67
|
-
(p) => {
|
|
68
|
-
showToast(`dayjs(date).format('YY年MM月DD日'))`);
|
|
69
|
-
console.log(p);
|
|
70
|
-
}
|
|
71
|
-
"
|
|
72
|
-
>
|
|
73
|
-
<template #trigger="{ triggerPopupShow, showValue }">
|
|
74
|
-
<div class="trigger-box">
|
|
75
|
-
<p>value:{{ modelValue }}</p>
|
|
76
|
-
<p>showValue:{{ showValue }}</p>
|
|
77
|
-
<van-button type="primary" @click="triggerPopupShow"> trigger </van-button>
|
|
78
|
-
</div>
|
|
79
|
-
</template>
|
|
80
|
-
</DatePicker>
|
|
81
|
-
</template>
|
|
82
|
-
|
|
83
|
-
<script setup lang="ts">
|
|
84
|
-
import { useWrapperRef } from '@ebfe/vhooks';
|
|
85
|
-
import { DatePicker } from '@ebfe/vant-kit';
|
|
86
|
-
import { Button as VanButton, showToast } from 'vant';
|
|
87
|
-
import dayjs from 'dayjs';
|
|
88
|
-
|
|
89
|
-
const [modelValue] = useWrapperRef('2030-03-04');
|
|
90
|
-
</script>
|
|
91
|
-
|
|
92
|
-
<style scoped lang="less">
|
|
93
|
-
.trigger-box {
|
|
94
|
-
display: flex;
|
|
95
|
-
flex-direction: column;
|
|
96
|
-
justify-content: center;
|
|
97
|
-
align-items: center;
|
|
98
|
-
}
|
|
99
|
-
</style>
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### 自定义 picker 打开时默认选中的值
|
|
103
|
-
|
|
104
|
-
modelValue 有值,则以 modelValue 为准
|
|
105
|
-
|
|
106
|
-
```html
|
|
107
|
-
<template>
|
|
108
|
-
<DatePicker ref="DatePickerRef" v-model="modelValue" :picker-props="{ title: '设置 picker 默认选中项' }">
|
|
109
|
-
<template #trigger="{ triggerPopupShow, pickerRealtimeOptions, showValue }">
|
|
110
|
-
<div class="trigger-box">
|
|
111
|
-
<p>value:{{ modelValue }}</p>
|
|
112
|
-
<p>showValue:{{ showValue }}</p>
|
|
113
|
-
<p>picker 实时选中值:{{ pickerRealtimeOptions }}</p>
|
|
114
|
-
<p>(modelValue 有值,则以 modelValue 为准)</p>
|
|
115
|
-
<van-space>
|
|
116
|
-
<van-button type="primary" @click="triggerPopupShow"> trigger </van-button>
|
|
117
|
-
<van-button type="warning" @click="() => DatePickerRef?.setPickerRealtimeDate('2035-05-06')">
|
|
118
|
-
2035-05-06
|
|
119
|
-
</van-button>
|
|
120
|
-
</van-space>
|
|
121
|
-
</div>
|
|
122
|
-
</template>
|
|
123
|
-
</DatePicker>
|
|
124
|
-
</template>
|
|
125
|
-
|
|
126
|
-
<script setup lang="ts">
|
|
127
|
-
import { useWrapperRef } from '@ebfe/vhooks';
|
|
128
|
-
import { DatePicker } from '@ebfe/vant-kit';
|
|
129
|
-
import { ref } from 'vue';
|
|
130
|
-
import { Button as VanButton, Space as VanSpace } from 'vant';
|
|
131
|
-
|
|
132
|
-
const [modelValue] = useWrapperRef('2030-03-04');
|
|
133
|
-
const DatePickerRef = ref<InstanceType<typeof DatePicker>>();
|
|
134
|
-
</script>
|
|
135
|
-
|
|
136
|
-
<style scoped lang="less">
|
|
137
|
-
.trigger-box {
|
|
138
|
-
display: flex;
|
|
139
|
-
flex-direction: column;
|
|
140
|
-
justify-content: center;
|
|
141
|
-
align-items: center;
|
|
142
|
-
}
|
|
143
|
-
</style>
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
### 支持所有 date-picker props
|
|
147
|
-
|
|
148
|
-
例如设置 columnsType 为: 月日
|
|
149
|
-
|
|
150
|
-
```html
|
|
151
|
-
<template>
|
|
152
|
-
<DatePicker v-model="modelValue" :picker-props="{ title: '基础用法', columnsType: ['month', 'day'] }">
|
|
153
|
-
<template #trigger="{ triggerPopupShow, showValue }">
|
|
154
|
-
<div class="trigger-box">
|
|
155
|
-
<p>value:{{ modelValue }}</p>
|
|
156
|
-
<p>showValue:{{ showValue }}</p>
|
|
157
|
-
<van-button @click="triggerPopupShow"> trigger </van-button>
|
|
158
|
-
</div>
|
|
159
|
-
</template>
|
|
160
|
-
</DatePicker>
|
|
161
|
-
</template>
|
|
162
|
-
|
|
163
|
-
<script setup lang="ts">
|
|
164
|
-
import { useWrapperRef } from '@ebfe/vhooks';
|
|
165
|
-
import { DatePicker } from '@ebfe/vant-kit';
|
|
166
|
-
import { Button as VanButton } from 'vant';
|
|
167
|
-
|
|
168
|
-
const [modelValue] = useWrapperRef('');
|
|
169
|
-
</script>
|
|
170
|
-
|
|
171
|
-
<style scoped lang="less">
|
|
172
|
-
.trigger-box {
|
|
173
|
-
display: flex;
|
|
174
|
-
flex-direction: column;
|
|
175
|
-
justify-content: center;
|
|
176
|
-
align-items: center;
|
|
177
|
-
}
|
|
178
|
-
</style>
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### 支持所有 date-picker slots
|
|
182
|
-
|
|
183
|
-
例如设置 columns-top
|
|
184
|
-
|
|
185
|
-
```html
|
|
186
|
-
<template>
|
|
187
|
-
<DatePicker v-model="modelValue" :picker-props="{ title: '基础用法' }">
|
|
188
|
-
<template #trigger="{ triggerPopupShow }">
|
|
189
|
-
<div class="trigger-box">
|
|
190
|
-
<van-button @click="triggerPopupShow"> trigger </van-button>
|
|
191
|
-
</div>
|
|
192
|
-
</template>
|
|
193
|
-
<template #columns-top>
|
|
194
|
-
<div class="columns-top-bar">
|
|
195
|
-
<span>这里是 columns-top 插槽内容</span>
|
|
196
|
-
</div>
|
|
197
|
-
</template>
|
|
198
|
-
</DatePicker>
|
|
199
|
-
</template>
|
|
200
|
-
|
|
201
|
-
<script setup lang="ts">
|
|
202
|
-
import { useWrapperRef } from '@ebfe/vhooks';
|
|
203
|
-
import { DatePicker } from '@ebfe/vant-kit';
|
|
204
|
-
import { Button as VanButton } from 'vant';
|
|
205
|
-
|
|
206
|
-
const [modelValue] = useWrapperRef('');
|
|
207
|
-
</script>
|
|
208
|
-
|
|
209
|
-
<style scoped lang="less">
|
|
210
|
-
.trigger-box {
|
|
211
|
-
display: flex;
|
|
212
|
-
flex-direction: column;
|
|
213
|
-
justify-content: center;
|
|
214
|
-
align-items: center;
|
|
215
|
-
}
|
|
216
|
-
.columns-top-bar {
|
|
217
|
-
display: flex;
|
|
218
|
-
justify-content: center;
|
|
219
|
-
align-items: center;
|
|
220
|
-
}
|
|
221
|
-
</style>
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
## API
|
|
225
|
-
|
|
226
|
-
### Props
|
|
227
|
-
|
|
228
|
-
TDatePickerProps
|
|
229
|
-
|
|
230
|
-
| 参数 | 说明 | 类型 | 默认值 |
|
|
231
|
-
| ------------------ | ----------------------------------------------------------------------------- | ---------------------------------------------- | ------ |
|
|
232
|
-
| modelValue | 值 | string | - |
|
|
233
|
-
| pickerProps | [date-picker props](https://vant-ui.github.io/vant/#/zh-CN/date-picker#props) | `Partial<DatePickerProps>` | - |
|
|
234
|
-
| showValueFormatter | 自定义展示值 | `showValueFormatter?: (date?: Date) => string` | - |
|
|
235
|
-
|
|
236
|
-
### Slots
|
|
237
|
-
|
|
238
|
-
支持暴露所有 [date-picker slots](https://vant-ui.github.io/vant/#/zh-CN/date-picker#slots)
|
|
239
|
-
|
|
240
|
-
| 插槽名 | 说明 | 参数 |
|
|
241
|
-
| ------- | ------ | ------------------------------------------------------- |
|
|
242
|
-
| trigger | 触发器 | `{ triggerPopupShow, showValue, pickerRealtimeOptions}` |
|
|
243
|
-
|
|
244
|
-
### 方法
|
|
245
|
-
|
|
246
|
-
| 方法名 | 说明 | 类型 |
|
|
247
|
-
| :-------------------- | :--------------------------------------------------------------------- | :--------------------------- |
|
|
248
|
-
| setPickerRealtimeDate | 设置 picker 打开时默认选中的值(modelValue 有值,则以modelValue 为准) | `(newValue: string) => void` |
|
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
# DateRangePicker
|
|
2
|
-
|
|
3
|
-
### 介绍
|
|
4
|
-
|
|
5
|
-
主要基于 vant 的 popup、picker-group、date-picker 组件进行二次封装,方便处理时间选择的需求场景。
|
|
6
|
-
|
|
7
|
-
- 支持传入所有 [date-picker props](https://vant-ui.github.io/vant/#/zh-CN/date-picker#props)
|
|
8
|
-
- 支持传入所有 [picker-group props](https://vant-ui.github.io/vant/#/zh-CN/picker-group#props)
|
|
9
|
-
- 支持暴露所有 [picker-group slots](https://vant-ui.github.io/vant/#/zh-CN/picker-group#slots)
|
|
10
|
-
|
|
11
|
-
**主要功能描述**
|
|
12
|
-
|
|
13
|
-
- 支持自定义触发器
|
|
14
|
-
- 支持自定义展示值
|
|
15
|
-
- 支持更改 picker 打开时默认选中的值(modelValue 有值,则以 modelValue 为准)
|
|
16
|
-
- 支持根据选择的时间大小自动矫正 values 的顺序
|
|
17
|
-
- 支持确认前的自定义拦截处理逻辑
|
|
18
|
-
|
|
19
|
-
**对开发者的解脱**
|
|
20
|
-
|
|
21
|
-
- 符合 ui 设计
|
|
22
|
-
- 默认处理选项的 formatter
|
|
23
|
-
- 默认 title、tabs、nextStepText 配置
|
|
24
|
-
- 无脑的双向绑定 values,自动矫正时间顺序
|
|
25
|
-
- 打开收起逻辑的编写
|
|
26
|
-
- 对所选项 `真实值`、`展示值` 的隔离和处理
|
|
27
|
-
|
|
28
|
-
## 代码演示
|
|
29
|
-
|
|
30
|
-
### 基础用法
|
|
31
|
-
|
|
32
|
-
```html
|
|
33
|
-
<template>
|
|
34
|
-
<DateRangePicker v-model="modelValue" :picker-group-props="{ title: '基础用法' }">
|
|
35
|
-
<template #trigger="{ triggerPopupShow, showValue }">
|
|
36
|
-
<div class="trigger-box">
|
|
37
|
-
<p>value: {{ modelValue }}</p>
|
|
38
|
-
<p>showValue: {{ showValue }}</p>
|
|
39
|
-
<van-button @click="triggerPopupShow"> trigger </van-button>
|
|
40
|
-
</div>
|
|
41
|
-
</template>
|
|
42
|
-
</DateRangePicker>
|
|
43
|
-
</template>
|
|
44
|
-
|
|
45
|
-
<script setup lang="ts">
|
|
46
|
-
import { useWrapperRef } from '@ebfe/vhooks';
|
|
47
|
-
import { DateRangePicker } from '@ebfe/vant-kit';
|
|
48
|
-
import { Button as VanButton } from 'vant';
|
|
49
|
-
|
|
50
|
-
const [modelValue] = useWrapperRef<[string, string]>(['', '']);
|
|
51
|
-
</script>
|
|
52
|
-
|
|
53
|
-
<style scoped lang="less">
|
|
54
|
-
.trigger-box {
|
|
55
|
-
display: flex;
|
|
56
|
-
flex-direction: column;
|
|
57
|
-
justify-content: center;
|
|
58
|
-
align-items: center;
|
|
59
|
-
}
|
|
60
|
-
</style>
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### 格式化展示值
|
|
64
|
-
|
|
65
|
-
props:`showValueFormatter?: (p: { startDate?: Date; endDate?: Date }) => string`
|
|
66
|
-
|
|
67
|
-
```html
|
|
68
|
-
<template>
|
|
69
|
-
<DateRangePicker
|
|
70
|
-
v-model="modelValue"
|
|
71
|
-
:show-value-formatter="
|
|
72
|
-
({ startDate, endDate }) => {
|
|
73
|
-
if (startDate && endDate) {
|
|
74
|
-
return (
|
|
75
|
-
dayjs(startDate).format('YY年MM月DD日') +
|
|
76
|
-
' / ' +
|
|
77
|
-
dayjs(endDate).format('YY年MM月DD日')
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
"
|
|
82
|
-
:picker-group-props="{ title: '格式化展示值' }"
|
|
83
|
-
@confirm="
|
|
84
|
-
(p) => {
|
|
85
|
-
showToast(`dayjs(date).format('YY年MM月DD日'))`);
|
|
86
|
-
console.log(p);
|
|
87
|
-
}
|
|
88
|
-
"
|
|
89
|
-
>
|
|
90
|
-
<template #trigger="{ triggerPopupShow, showValue }">
|
|
91
|
-
<div class="trigger-box">
|
|
92
|
-
<p>value: {{ modelValue }}</p>
|
|
93
|
-
<p>showValue: {{ showValue }}</p>
|
|
94
|
-
<van-button type="primary" @click="triggerPopupShow"> trigger </van-button>
|
|
95
|
-
</div>
|
|
96
|
-
</template>
|
|
97
|
-
</DateRangePicker>
|
|
98
|
-
</template>
|
|
99
|
-
|
|
100
|
-
<script setup lang="ts">
|
|
101
|
-
import { useWrapperRef } from '@ebfe/vhooks';
|
|
102
|
-
import { DateRangePicker } from '@ebfe/vant-kit';
|
|
103
|
-
import { Button as VanButton, showToast } from 'vant';
|
|
104
|
-
import dayjs from 'dayjs';
|
|
105
|
-
|
|
106
|
-
const [modelValue] = useWrapperRef<[string, string]>(['2020-03-04', '2030-05-06']);
|
|
107
|
-
</script>
|
|
108
|
-
|
|
109
|
-
<style scoped lang="less">
|
|
110
|
-
.trigger-box {
|
|
111
|
-
display: flex;
|
|
112
|
-
flex-direction: column;
|
|
113
|
-
justify-content: center;
|
|
114
|
-
align-items: center;
|
|
115
|
-
}
|
|
116
|
-
</style>
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### 自定义 picker 打开时默认选中的值
|
|
120
|
-
|
|
121
|
-
modelValue 有值,则以 modelValue 为准
|
|
122
|
-
|
|
123
|
-
```html
|
|
124
|
-
<template>
|
|
125
|
-
<DateRangePicker
|
|
126
|
-
ref="DateRangePickerRef"
|
|
127
|
-
v-model="modelValue"
|
|
128
|
-
:picker-group-props="{ title: '设置 picker 默认选中项' }"
|
|
129
|
-
>
|
|
130
|
-
<template #trigger="{ triggerPopupShow, pickerRealtimeOptions, showValue }">
|
|
131
|
-
<div class="trigger-box">
|
|
132
|
-
<p>value:{{ modelValue }}</p>
|
|
133
|
-
<p>showValue:{{ showValue }}</p>
|
|
134
|
-
<p>picker 实时选中值👇</p>
|
|
135
|
-
<p>{{ pickerRealtimeOptions }}</p>
|
|
136
|
-
<p>(modelValue 有值,则以 modelValue 为准)</p>
|
|
137
|
-
<van-space>
|
|
138
|
-
<van-button type="primary" @click="triggerPopupShow"> trigger </van-button>
|
|
139
|
-
<van-button
|
|
140
|
-
type="warning"
|
|
141
|
-
@click="
|
|
142
|
-
() =>
|
|
143
|
-
DateRangePickerRef?.setPickerRealtimeDate({
|
|
144
|
-
start: '2022-02-02',
|
|
145
|
-
end: '2033-03-03',
|
|
146
|
-
})
|
|
147
|
-
"
|
|
148
|
-
>
|
|
149
|
-
2022-02-02 ~ 2033-03-03
|
|
150
|
-
</van-button>
|
|
151
|
-
</van-space>
|
|
152
|
-
</div>
|
|
153
|
-
</template>
|
|
154
|
-
</DateRangePicker>
|
|
155
|
-
</template>
|
|
156
|
-
|
|
157
|
-
<script setup lang="ts">
|
|
158
|
-
import { useWrapperRef } from '@ebfe/vhooks';
|
|
159
|
-
import { DateRangePicker } from '@ebfe/vant-kit';
|
|
160
|
-
import { ref } from 'vue';
|
|
161
|
-
import { Button as VanButton, Space as VanSpace } from 'vant';
|
|
162
|
-
|
|
163
|
-
const DateRangePickerRef = ref<InstanceType<typeof DateRangePicker>>();
|
|
164
|
-
|
|
165
|
-
const [modelValue] = useWrapperRef<[string, string]>(['2020-03-04', '2030-05-06']);
|
|
166
|
-
</script>
|
|
167
|
-
|
|
168
|
-
<style scoped lang="less">
|
|
169
|
-
.trigger-box {
|
|
170
|
-
display: flex;
|
|
171
|
-
flex-direction: column;
|
|
172
|
-
justify-content: center;
|
|
173
|
-
align-items: center;
|
|
174
|
-
}
|
|
175
|
-
</style>
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
### 确认前的自定义拦截处理逻辑
|
|
179
|
-
|
|
180
|
-
props:`beforeConfirm?: (newValues: string[]) => boolean;`
|
|
181
|
-
|
|
182
|
-
- 返回 true,values 正常更新,弹窗关闭
|
|
183
|
-
- 返回 false,则什么都不做
|
|
184
|
-
|
|
185
|
-
```html
|
|
186
|
-
<template>
|
|
187
|
-
<DateRangePicker
|
|
188
|
-
v-model="modelValue"
|
|
189
|
-
:picker-group-props="{ title: 'beforeConfirm' }"
|
|
190
|
-
:before-confirm="
|
|
191
|
-
(values) => {
|
|
192
|
-
const [start, end] = values;
|
|
193
|
-
if (start == dayjs().format('YYYY-MM-DD') && start === end) {
|
|
194
|
-
return true;
|
|
195
|
-
}
|
|
196
|
-
showFailToast('请选择当前日期');
|
|
197
|
-
return false;
|
|
198
|
-
}
|
|
199
|
-
"
|
|
200
|
-
>
|
|
201
|
-
<template #trigger="{ triggerPopupShow, showValue }">
|
|
202
|
-
<div class="trigger-box">
|
|
203
|
-
<p>value: {{ modelValue }}</p>
|
|
204
|
-
<p>showValue: {{ showValue }}</p>
|
|
205
|
-
<van-button @click="triggerPopupShow"> trigger </van-button>
|
|
206
|
-
</div>
|
|
207
|
-
</template>
|
|
208
|
-
</DateRangePicker>
|
|
209
|
-
</template>
|
|
210
|
-
|
|
211
|
-
<script setup lang="ts">
|
|
212
|
-
import { useWrapperRef } from '@ebfe/vhooks';
|
|
213
|
-
import { DateRangePicker } from '@ebfe/vant-kit';
|
|
214
|
-
import { showFailToast, Button as VanButton } from 'vant';
|
|
215
|
-
import dayjs from 'dayjs';
|
|
216
|
-
|
|
217
|
-
const [modelValue] = useWrapperRef<[string, string]>(['', '']);
|
|
218
|
-
</script>
|
|
219
|
-
|
|
220
|
-
<style scoped lang="less">
|
|
221
|
-
.trigger-box {
|
|
222
|
-
display: flex;
|
|
223
|
-
flex-direction: column;
|
|
224
|
-
justify-content: center;
|
|
225
|
-
align-items: center;
|
|
226
|
-
}
|
|
227
|
-
</style>
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
### 支持所有 date-picker props
|
|
231
|
-
|
|
232
|
-
例如设置 columnsType 为: 月日
|
|
233
|
-
|
|
234
|
-
```html
|
|
235
|
-
<template>
|
|
236
|
-
<DateRangePicker
|
|
237
|
-
v-model="modelValue"
|
|
238
|
-
:picker-group-props="{ title: '设置 columnsType' }"
|
|
239
|
-
:picker-props="{ columnsType: ['month', 'day'] }"
|
|
240
|
-
>
|
|
241
|
-
<template #trigger="{ triggerPopupShow, showValue }">
|
|
242
|
-
<div class="trigger-box">
|
|
243
|
-
<p>value: {{ modelValue }}</p>
|
|
244
|
-
<p>showValue: {{ showValue }}</p>
|
|
245
|
-
<van-button @click="triggerPopupShow"> trigger </van-button>
|
|
246
|
-
</div>
|
|
247
|
-
</template>
|
|
248
|
-
</DateRangePicker>
|
|
249
|
-
</template>
|
|
250
|
-
|
|
251
|
-
<script setup lang="ts">
|
|
252
|
-
import { useWrapperRef } from '@ebfe/vhooks';
|
|
253
|
-
import { DateRangePicker } from '@ebfe/vant-kit';
|
|
254
|
-
import { Button as VanButton } from 'vant';
|
|
255
|
-
|
|
256
|
-
const [modelValue] = useWrapperRef<[string, string]>(['', '']);
|
|
257
|
-
</script>
|
|
258
|
-
|
|
259
|
-
<style scoped lang="less">
|
|
260
|
-
.trigger-box {
|
|
261
|
-
display: flex;
|
|
262
|
-
flex-direction: column;
|
|
263
|
-
justify-content: center;
|
|
264
|
-
align-items: center;
|
|
265
|
-
}
|
|
266
|
-
</style>
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
### 支持所有 picker-group props
|
|
270
|
-
|
|
271
|
-
例如设置 confirmButtonText
|
|
272
|
-
|
|
273
|
-
```html
|
|
274
|
-
<template>
|
|
275
|
-
<DateRangePicker
|
|
276
|
-
v-model="modelValue"
|
|
277
|
-
:picker-group-props="{
|
|
278
|
-
title: '设置 confirmButtonText',
|
|
279
|
-
confirmButtonText: '👉✅👈',
|
|
280
|
-
}"
|
|
281
|
-
>
|
|
282
|
-
<template #trigger="{ triggerPopupShow }">
|
|
283
|
-
<div class="trigger-box">
|
|
284
|
-
<van-button @click="triggerPopupShow"> trigger </van-button>
|
|
285
|
-
</div>
|
|
286
|
-
</template>
|
|
287
|
-
</DateRangePicker>
|
|
288
|
-
</template>
|
|
289
|
-
|
|
290
|
-
<script setup lang="ts">
|
|
291
|
-
import { useWrapperRef } from '@ebfe/vhooks';
|
|
292
|
-
import { DateRangePicker } from '@ebfe/vant-kit';
|
|
293
|
-
import { Button as VanButton } from 'vant';
|
|
294
|
-
|
|
295
|
-
const [modelValue] = useWrapperRef<[string, string]>(['', '']);
|
|
296
|
-
</script>
|
|
297
|
-
|
|
298
|
-
<style scoped lang="less">
|
|
299
|
-
.trigger-box {
|
|
300
|
-
display: flex;
|
|
301
|
-
flex-direction: column;
|
|
302
|
-
justify-content: center;
|
|
303
|
-
align-items: center;
|
|
304
|
-
}
|
|
305
|
-
</style>
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
### 支持所有 picker-group slots
|
|
309
|
-
|
|
310
|
-
例如设置 toolbar
|
|
311
|
-
|
|
312
|
-
```html
|
|
313
|
-
<template>
|
|
314
|
-
<DateRangePicker v-model="modelValue" :picker-group-props="{ title: '设置 toolbar' }">
|
|
315
|
-
<template #trigger="{ triggerPopupShow }">
|
|
316
|
-
<div class="trigger-box">
|
|
317
|
-
<van-button @click="triggerPopupShow"> trigger </van-button>
|
|
318
|
-
</div>
|
|
319
|
-
</template>
|
|
320
|
-
|
|
321
|
-
<template #toolbar> 👉自定义工具栏👈 </template>
|
|
322
|
-
</DateRangePicker>
|
|
323
|
-
</template>
|
|
324
|
-
|
|
325
|
-
<script setup lang="ts">
|
|
326
|
-
import { useWrapperRef } from '@ebfe/vhooks';
|
|
327
|
-
import { DateRangePicker } from '@ebfe/vant-kit';
|
|
328
|
-
import { Button as VanButton } from 'vant';
|
|
329
|
-
|
|
330
|
-
const [modelValue] = useWrapperRef<[string, string]>(['', '']);
|
|
331
|
-
</script>
|
|
332
|
-
|
|
333
|
-
<style scoped lang="less">
|
|
334
|
-
.trigger-box {
|
|
335
|
-
display: flex;
|
|
336
|
-
flex-direction: column;
|
|
337
|
-
justify-content: center;
|
|
338
|
-
align-items: center;
|
|
339
|
-
}
|
|
340
|
-
</style>
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
## API
|
|
344
|
-
|
|
345
|
-
### Props
|
|
346
|
-
|
|
347
|
-
TDatePickerProps
|
|
348
|
-
|
|
349
|
-
| 参数 | 说明 | 类型 | 默认值 |
|
|
350
|
-
| ------------------ | ------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ------ |
|
|
351
|
-
| modelValue | 值 | `string[]` | - |
|
|
352
|
-
| pickerProps | [date-picker props](https://vant-ui.github.io/vant/#/zh-CN/date-picker#props) | `Partial<DatePickerProps>` | - |
|
|
353
|
-
| pickerGroupProps | [picker-group props](https://vant-ui.github.io/vant/#/zh-CN/picker-group#props) | `Partial<PickerGroupProps>` | - |
|
|
354
|
-
| showValueFormatter | 自定义展示值 | `showValueFormatter?: (p: { startDate?: Date; endDate?: Date }) => string` | - |
|
|
355
|
-
| beforeConfirm | 确认前的自定义拦截处理逻辑 | `beforeConfirm?: (newValues: TDateRangePickerProps['modelValue']) => boolean` | - |
|
|
356
|
-
|
|
357
|
-
### Slots
|
|
358
|
-
|
|
359
|
-
支持暴露所有 [picker-group slots](https://vant-ui.github.io/vant/#/zh-CN/picker-group#slots)
|
|
360
|
-
|
|
361
|
-
| 插槽名 | 说明 | 参数 |
|
|
362
|
-
| ------- | ------ | ------------------------------------------------------- |
|
|
363
|
-
| trigger | 触发器 | `{ showValue, triggerPopupShow, pickerRealtimeOptions}` |
|
|
364
|
-
|
|
365
|
-
### 方法
|
|
366
|
-
|
|
367
|
-
| 方法名 | 说明 | 类型 |
|
|
368
|
-
| :-------------------- | :--------------------------------------------------------------------- | :-------------------------------------------- |
|
|
369
|
-
| setPickerRealtimeDate | 设置 picker 打开时默认选中的值(modelValue 有值,则以modelValue 为准) | `(p: { start: string; end: string }) => void` |
|