@fox-js/phone-skills 4.0.1-0
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/README.md +30 -0
- package/foxui/SKILL.md +442 -0
- package/foxui/references/fox-action-sheet/doc.md +74 -0
- package/foxui/references/fox-actionsheet-item/doc.md +499 -0
- package/foxui/references/fox-animate/doc.md +66 -0
- package/foxui/references/fox-audio/doc.md +76 -0
- package/foxui/references/fox-avatar/doc.md +70 -0
- package/foxui/references/fox-back-top/doc.md +69 -0
- package/foxui/references/fox-badge/doc.md +72 -0
- package/foxui/references/fox-barrage/doc.md +116 -0
- package/foxui/references/fox-button/doc.md +203 -0
- package/foxui/references/fox-calendar/doc.md +346 -0
- package/foxui/references/fox-calendar-item/doc.md +331 -0
- package/foxui/references/fox-cascader/doc.md +78 -0
- package/foxui/references/fox-cascader-item/doc.md +710 -0
- package/foxui/references/fox-cell/doc.md +74 -0
- package/foxui/references/fox-checkbox-item/doc.md +387 -0
- package/foxui/references/fox-circle-progress/doc.md +65 -0
- package/foxui/references/fox-collapse/doc.md +71 -0
- package/foxui/references/fox-count-down/doc.md +78 -0
- package/foxui/references/fox-count-up/doc.md +178 -0
- package/foxui/references/fox-date-item/doc.md +437 -0
- package/foxui/references/fox-date-picker/doc.md +438 -0
- package/foxui/references/fox-dialog/doc.md +242 -0
- package/foxui/references/fox-divider/doc.md +149 -0
- package/foxui/references/fox-domain-provider/doc.md +93 -0
- package/foxui/references/fox-drag/doc.md +64 -0
- package/foxui/references/fox-dropdown/doc.md +138 -0
- package/foxui/references/fox-elevator/doc.md +66 -0
- package/foxui/references/fox-ellipsis/doc.md +69 -0
- package/foxui/references/fox-empty/doc.md +67 -0
- package/foxui/references/fox-fixed-nav/doc.md +72 -0
- package/foxui/references/fox-floating-button/doc.md +142 -0
- package/foxui/references/fox-grid/doc.md +69 -0
- package/foxui/references/fox-group/doc.md +295 -0
- package/foxui/references/fox-icon/doc.md +65 -0
- package/foxui/references/fox-image/doc.md +75 -0
- package/foxui/references/fox-image-preview/doc.md +79 -0
- package/foxui/references/fox-indicator/doc.md +70 -0
- package/foxui/references/fox-infinite-loading/doc.md +74 -0
- package/foxui/references/fox-input-item/doc.md +210 -0
- package/foxui/references/fox-input-number/doc.md +199 -0
- package/foxui/references/fox-input-number-item/doc.md +213 -0
- package/foxui/references/fox-item/doc.md +207 -0
- package/foxui/references/fox-layout/doc.md +273 -0
- package/foxui/references/fox-link-item/doc.md +158 -0
- package/foxui/references/fox-list/doc.md +71 -0
- package/foxui/references/fox-mapping/doc.md +251 -0
- package/foxui/references/fox-menu/doc.md +425 -0
- package/foxui/references/fox-message-box/doc.md +200 -0
- package/foxui/references/fox-money-item/doc.md +174 -0
- package/foxui/references/fox-more-button/doc.md +208 -0
- package/foxui/references/fox-navbar/doc.md +75 -0
- package/foxui/references/fox-notice-bar/doc.md +71 -0
- package/foxui/references/fox-notify/doc.md +72 -0
- package/foxui/references/fox-number-keyboard/doc.md +77 -0
- package/foxui/references/fox-over-lay/doc.md +70 -0
- package/foxui/references/fox-page/doc.md +76 -0
- package/foxui/references/fox-pagination/doc.md +73 -0
- package/foxui/references/fox-picker/doc.md +668 -0
- package/foxui/references/fox-picker-item/doc.md +389 -0
- package/foxui/references/fox-popover/doc.md +70 -0
- package/foxui/references/fox-popover-dialog/doc.md +113 -0
- package/foxui/references/fox-popup/doc.md +88 -0
- package/foxui/references/fox-price/doc.md +67 -0
- package/foxui/references/fox-progress/doc.md +74 -0
- package/foxui/references/fox-pull-refresh/doc.md +77 -0
- package/foxui/references/fox-radio-item/doc.md +384 -0
- package/foxui/references/fox-range/doc.md +65 -0
- package/foxui/references/fox-rate/doc.md +141 -0
- package/foxui/references/fox-rate-item/doc.md +137 -0
- package/foxui/references/fox-rolling-provider/doc.md +87 -0
- package/foxui/references/fox-search-bar/doc.md +91 -0
- package/foxui/references/fox-short-password/doc.md +78 -0
- package/foxui/references/fox-side-nav-bar/doc.md +68 -0
- package/foxui/references/fox-signature/doc.md +202 -0
- package/foxui/references/fox-skeleton/doc.md +73 -0
- package/foxui/references/fox-steps/doc.md +162 -0
- package/foxui/references/fox-steps-bar/doc.md +610 -0
- package/foxui/references/fox-sticky/doc.md +68 -0
- package/foxui/references/fox-swipe/doc.md +176 -0
- package/foxui/references/fox-swiper/doc.md +254 -0
- package/foxui/references/fox-switch/doc.md +162 -0
- package/foxui/references/fox-switch-item/doc.md +190 -0
- package/foxui/references/fox-tabbar/doc.md +63 -0
- package/foxui/references/fox-table/doc.md +640 -0
- package/foxui/references/fox-tabs/doc.md +67 -0
- package/foxui/references/fox-tabs-bar/doc.md +533 -0
- package/foxui/references/fox-tag/doc.md +213 -0
- package/foxui/references/fox-text/doc.md +84 -0
- package/foxui/references/fox-textarea-item/doc.md +106 -0
- package/foxui/references/fox-toast/doc.md +149 -0
- package/foxui/references/fox-tour/doc.md +89 -0
- package/foxui/references/fox-trend-arrow/doc.md +72 -0
- package/foxui/references/fox-uploader/doc.md +96 -0
- package/foxui/references/fox-video/doc.md +245 -0
- package/foxui/references/fox-water-mark/doc.md +81 -0
- package/package.json +21 -0
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: 江成
|
|
3
|
+
* @Date: 2026-04-27 00:37:28
|
|
4
|
+
* @LastEditors: 江成
|
|
5
|
+
* @LastEditTime: 2026-05-12 22:33:21
|
|
6
|
+
-->
|
|
7
|
+
---
|
|
8
|
+
title: DatePicker 组件使用规范
|
|
9
|
+
impact: HIGH
|
|
10
|
+
type: capability
|
|
11
|
+
description: 提供多个选型集合供用户选择,支持单列选择和多列级联,通常与弹出层配合使用
|
|
12
|
+
tags: [foxui, fox-date-picker, FoxDatePicker]
|
|
13
|
+
version: "4.0.0"
|
|
14
|
+
author: jiangcheng
|
|
15
|
+
related: ["fox-js","fox-date-item","fox-group","fox-button"]
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# DatePicker 组件使用规范
|
|
19
|
+
|
|
20
|
+
## 1. 核心职责 (Core Responsibility)
|
|
21
|
+
DatePicker 是 foxui 中用于 **提供多个选型集合供用户选择,支持单列选择和多列级联,通常与弹出层配合使用** 的标准组件。
|
|
22
|
+
- **基于**: NutUI `nut-date-picker` 进行了二次封装 (若为纯自研组件则填 "自定义开发")
|
|
23
|
+
- **核心增强**: 基于 NutUI 组件二次封装、内置必填校验标识、支持 v-model 双向绑定、支持标签位置自定义、支持占位符提示、支持禁用/只读状态、内置多级提示信息、支持插槽扩展自定义内容
|
|
24
|
+
- **适用场景**: 提供多个选型集合供用户选择,支持单列选择和多列级联,通常与弹出层配合使用
|
|
25
|
+
|
|
26
|
+
> 💡 **关键原则**: 在所有 提供多个选型集合供用户选择,支持单列选择和多列级联,通常与弹出层配合使用 中,**必须**优先使用此组件,禁止直接使用原生 NutUI 组件。
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 2. 关键 API 说明 (Key API)
|
|
31
|
+
|
|
32
|
+
### 2.1 Props 属性
|
|
33
|
+
|
|
34
|
+
| 属性名 | 类型 | 必填 | 默认值 | 说明 |
|
|
35
|
+
| :--- | :--- | :---: | :---: | :--- |
|
|
36
|
+
| `date` | 日期类型(YYYY-MM-DD) |
|
|
37
|
+
| `datetime` | 日期时间类型(YYYY-MM-DD HH:mm:ss) |
|
|
38
|
+
| `time` | 时间类型(HH:mm:ss) |
|
|
39
|
+
| `year-month` | 年月类型(YYYY-MM) |
|
|
40
|
+
| `month-day` | 月天类型(MM-DD) |
|
|
41
|
+
| `hour-minute` | 时分类型(HH-mm) |
|
|
42
|
+
| `datehour` | 带小时的日期类型(YYYY-MM-DD HH) |
|
|
43
|
+
|
|
44
|
+
### 2.2 Events 事件
|
|
45
|
+
|
|
46
|
+
| 事件名 | 类型 | 说明 |
|
|
47
|
+
| :--- | :--- | :--- |
|
|
48
|
+
| `change` | 输入内容时触发 | val ,event |
|
|
49
|
+
| `focus` | 聚焦时触发 | val ,event |
|
|
50
|
+
| `blur` | 失焦时触发 | val ,event |
|
|
51
|
+
| `clear` | 点击清空时触发 | val |
|
|
52
|
+
|
|
53
|
+
### 2.3 Methods 方法
|
|
54
|
+
|
|
55
|
+
| 方法名 | 参数 | 说明 |
|
|
56
|
+
| :--- | :--- | :--- |
|
|
57
|
+
无
|
|
58
|
+
|
|
59
|
+
### 2.4 Slots 插槽
|
|
60
|
+
|
|
61
|
+
| 插槽名 | 说明 |
|
|
62
|
+
| :--- | :--- |
|
|
63
|
+
| `default` | 输入框标签内容 |
|
|
64
|
+
| `prepend` | 输入框左侧内容 |
|
|
65
|
+
| `append` | 输入框右侧内容 |
|
|
66
|
+
| `top` | 弹出选择框顶部内容 |
|
|
67
|
+
| `bottom` | 弹出选择框底部内容 |
|
|
68
|
+
|
|
69
|
+
## 3. 例子 (Examples)
|
|
70
|
+
|
|
71
|
+
## 代码演示
|
|
72
|
+
### date类型
|
|
73
|
+
```html
|
|
74
|
+
<fox-date-item v-model="val">日期框</fox-date-item>
|
|
75
|
+
<fox-date-item v-model="val2" :min-date="minDate" :max-date="maxDate" :value-format="formatTemplates.date">value格式化</fox-date-item>
|
|
76
|
+
<fox-date-item v-model="val3" :value-format="formatTemplates.date" :format="formatTemplates.textDate">text格式化</fox-date-item>
|
|
77
|
+
```
|
|
78
|
+
```javascript
|
|
79
|
+
export default createDemo({
|
|
80
|
+
// setup
|
|
81
|
+
setup() {
|
|
82
|
+
// 通用Format
|
|
83
|
+
const formatTemplates: Record<string, string> = {
|
|
84
|
+
date: 'YYYY-MM-DD',
|
|
85
|
+
textDate: 'YYYY年MM月DD日',
|
|
86
|
+
datetime: 'YYYY-MM-DD HH:mm:ss',
|
|
87
|
+
textDatetime: 'YYYY/MM/DD HH:mm:ss',
|
|
88
|
+
time: 'HH:mm:ss',
|
|
89
|
+
['month-day']: 'MM-DD',
|
|
90
|
+
datehour: 'YYYY年MM月DD日 HH时'
|
|
91
|
+
}
|
|
92
|
+
const tody = new Date()
|
|
93
|
+
// 数据
|
|
94
|
+
const data = reactive({
|
|
95
|
+
minDate: new Date(2010, 0, 1),
|
|
96
|
+
maxDate: new Date(2050, 11, 31),
|
|
97
|
+
val: tody,
|
|
98
|
+
val2: DateUtils.format(tody, formatTemplates.date),
|
|
99
|
+
val3: '',
|
|
100
|
+
})
|
|
101
|
+
watch(
|
|
102
|
+
() => data.val,
|
|
103
|
+
newVal => {
|
|
104
|
+
console.info('val', newVal)
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
watch(
|
|
108
|
+
() => data.val2,
|
|
109
|
+
newVal => {
|
|
110
|
+
console.info('val2', newVal)
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
watch(
|
|
114
|
+
() => data.val3,
|
|
115
|
+
newVal => {
|
|
116
|
+
console.info('val3', newVal)
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
watch(
|
|
120
|
+
() => data.val10,
|
|
121
|
+
newVal => {
|
|
122
|
+
console.info('val10', newVal)
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
return {
|
|
126
|
+
formatTemplates,
|
|
127
|
+
...toRefs(data)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
```
|
|
132
|
+
### datetime类型
|
|
133
|
+
```html
|
|
134
|
+
<fox-date-item type="datetime" v-model="val4">日期时间框</fox-date-item>
|
|
135
|
+
<fox-date-item type="datetime" v-model="val5" :min-date="minDate" :max-date="maxDate" :value-format="formatTemplates.datetime">value格式化</fox-date-item>
|
|
136
|
+
<fox-date-item type="datetime" v-model="val6" :value-format="formatTemplates.datetime" :format="formatTemplates.textDatetime">text格式化</fox-date-item>
|
|
137
|
+
```
|
|
138
|
+
```javascript
|
|
139
|
+
export default createDemo({
|
|
140
|
+
// setup
|
|
141
|
+
setup() {
|
|
142
|
+
// 通用Format
|
|
143
|
+
const formatTemplates: Record<string, string> = {
|
|
144
|
+
date: 'YYYY-MM-DD',
|
|
145
|
+
textDate: 'YYYY年MM月DD日',
|
|
146
|
+
datetime: 'YYYY-MM-DD HH:mm:ss',
|
|
147
|
+
textDatetime: 'YYYY/MM/DD HH:mm:ss',
|
|
148
|
+
time: 'HH:mm:ss',
|
|
149
|
+
['month-day']: 'MM-DD',
|
|
150
|
+
datehour: 'YYYY年MM月DD日 HH时'
|
|
151
|
+
}
|
|
152
|
+
const tody = new Date()
|
|
153
|
+
// 数据
|
|
154
|
+
const data = reactive({
|
|
155
|
+
minDate: new Date(2010, 0, 1),
|
|
156
|
+
maxDate: new Date(2050, 11, 31),
|
|
157
|
+
val4: new Date(2020, 0, 1),
|
|
158
|
+
val5: '',
|
|
159
|
+
val6: '',
|
|
160
|
+
})
|
|
161
|
+
return {
|
|
162
|
+
formatTemplates,
|
|
163
|
+
...toRefs(data)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
```
|
|
168
|
+
### time类型
|
|
169
|
+
```html
|
|
170
|
+
<fox-date-item type="time" v-model="val7" :value-format="formatTemplates.time" title="时间选择" :min-date="minDate" :max-date="maxDate">时间框</fox-date-item>
|
|
171
|
+
<fox-date-item type="time" v-model="val8" :value-format="formatTemplates.time" title="时间选择" :min-date="minDate" :minute-step="5" :max-date="maxDate">步长时间框</fox-date-item>
|
|
172
|
+
```
|
|
173
|
+
```javascript
|
|
174
|
+
export default createDemo({
|
|
175
|
+
// setup
|
|
176
|
+
setup() {
|
|
177
|
+
// 通用Format
|
|
178
|
+
const formatTemplates: Record<string, string> = {
|
|
179
|
+
date: 'YYYY-MM-DD',
|
|
180
|
+
textDate: 'YYYY年MM月DD日',
|
|
181
|
+
datetime: 'YYYY-MM-DD HH:mm:ss',
|
|
182
|
+
textDatetime: 'YYYY/MM/DD HH:mm:ss',
|
|
183
|
+
time: 'HH:mm:ss',
|
|
184
|
+
['month-day']: 'MM-DD',
|
|
185
|
+
datehour: 'YYYY年MM月DD日 HH时'
|
|
186
|
+
}
|
|
187
|
+
const tody = new Date()
|
|
188
|
+
// 数据
|
|
189
|
+
const data = reactive({
|
|
190
|
+
minDate: new Date(2010, 0, 1),
|
|
191
|
+
maxDate: new Date(2050, 11, 31),
|
|
192
|
+
val7: '',
|
|
193
|
+
val8: '',
|
|
194
|
+
})
|
|
195
|
+
return {
|
|
196
|
+
formatTemplates,
|
|
197
|
+
...toRefs(data)
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
})
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### year-month类型
|
|
204
|
+
|
|
205
|
+
```html
|
|
206
|
+
<fox-group title="year-month类型" label-width="120px">
|
|
207
|
+
<fox-date-item type="year-month" v-model="data.val8" :value-format="formatTemplates['year-month']" title="时间选择"
|
|
208
|
+
>时间选择</fox-date-item
|
|
209
|
+
>
|
|
210
|
+
</fox-group>
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
```javascript
|
|
214
|
+
export default createDemo({
|
|
215
|
+
// setup
|
|
216
|
+
setup() {
|
|
217
|
+
// 通用Format
|
|
218
|
+
const formatTemplates: Record<string, string> = {
|
|
219
|
+
date: 'YYYY-MM-DD',
|
|
220
|
+
textDate: 'YYYY年MM月DD日',
|
|
221
|
+
datetime: 'YYYY-MM-DD HH:mm:ss',
|
|
222
|
+
textDatetime: 'YYYY/MM/DD HH:mm:ss',
|
|
223
|
+
time: 'HH:mm:ss',
|
|
224
|
+
['year-month']: 'YY-MM',
|
|
225
|
+
['month-day']: 'MM-DD',
|
|
226
|
+
datehour: 'YYYY年MM月DD日 HH时'
|
|
227
|
+
}
|
|
228
|
+
const tody = new Date()
|
|
229
|
+
// 数据
|
|
230
|
+
const data = reactive({
|
|
231
|
+
minDate: new Date(2010, 0, 1),
|
|
232
|
+
maxDate: new Date(2050, 11, 31),
|
|
233
|
+
val8: ''
|
|
234
|
+
})
|
|
235
|
+
return {
|
|
236
|
+
formatTemplates,
|
|
237
|
+
...toRefs(data)
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
### month-day类型
|
|
247
|
+
```html
|
|
248
|
+
<fox-date-item type="month-day" v-model="val9" :value-format="formatTemplates['month-day']" title="时间选择">时间选择</fox-date-item>
|
|
249
|
+
```
|
|
250
|
+
```javascript
|
|
251
|
+
export default createDemo({
|
|
252
|
+
// setup
|
|
253
|
+
setup() {
|
|
254
|
+
// 通用Format
|
|
255
|
+
const formatTemplates: Record<string, string> = {
|
|
256
|
+
date: 'YYYY-MM-DD',
|
|
257
|
+
textDate: 'YYYY年MM月DD日',
|
|
258
|
+
datetime: 'YYYY-MM-DD HH:mm:ss',
|
|
259
|
+
textDatetime: 'YYYY/MM/DD HH:mm:ss',
|
|
260
|
+
time: 'HH:mm:ss',
|
|
261
|
+
['year-month']: 'YY-MM',
|
|
262
|
+
['month-day']: 'MM-DD',
|
|
263
|
+
datehour: 'YYYY年MM月DD日 HH时'
|
|
264
|
+
}
|
|
265
|
+
const tody = new Date()
|
|
266
|
+
// 数据
|
|
267
|
+
const data = reactive({
|
|
268
|
+
minDate: new Date(2010, 0, 1),
|
|
269
|
+
maxDate: new Date(2050, 11, 31),
|
|
270
|
+
val9: ''
|
|
271
|
+
})
|
|
272
|
+
return {
|
|
273
|
+
formatTemplates,
|
|
274
|
+
...toRefs(data)
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
})
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### datehour类型
|
|
281
|
+
```html
|
|
282
|
+
<fox-date-item type="datehour" v-model="val10" :value-format="formatTemplates['datehour']" title="时间选择">时间选择</fox-date-item>
|
|
283
|
+
```
|
|
284
|
+
```javascript
|
|
285
|
+
export default createDemo({
|
|
286
|
+
// setup
|
|
287
|
+
setup() {
|
|
288
|
+
// 通用Format
|
|
289
|
+
const formatTemplates: Record<string, string> = {
|
|
290
|
+
date: 'YYYY-MM-DD',
|
|
291
|
+
textDate: 'YYYY年MM月DD日',
|
|
292
|
+
datetime: 'YYYY-MM-DD HH:mm:ss',
|
|
293
|
+
textDatetime: 'YYYY/MM/DD HH:mm:ss',
|
|
294
|
+
time: 'HH:mm:ss',
|
|
295
|
+
['month-day']: 'MM-DD',
|
|
296
|
+
datehour: 'YYYY年MM月DD日 HH时'
|
|
297
|
+
}
|
|
298
|
+
const tody = new Date()
|
|
299
|
+
// 数据
|
|
300
|
+
const data = reactive({
|
|
301
|
+
minDate: new Date(2010, 0, 1),
|
|
302
|
+
maxDate: new Date(2050, 11, 31),
|
|
303
|
+
val10: ''
|
|
304
|
+
})
|
|
305
|
+
watch(
|
|
306
|
+
() => data.val10,
|
|
307
|
+
newVal => {
|
|
308
|
+
console.info('val10', newVal)
|
|
309
|
+
}
|
|
310
|
+
)
|
|
311
|
+
return {
|
|
312
|
+
formatTemplates,
|
|
313
|
+
...toRefs(data)
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
})
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### 自定义按钮
|
|
320
|
+
```html
|
|
321
|
+
<fox-date-item ref="dateRef" v-model="data.val11">
|
|
322
|
+
<template v-slot:default>日期框</template>
|
|
323
|
+
<template v-slot:bottom>
|
|
324
|
+
<fox-button block type="primary" @click="clearFunc">清空</fox-button>
|
|
325
|
+
</template>
|
|
326
|
+
</fox-date-item>
|
|
327
|
+
|
|
328
|
+
```
|
|
329
|
+
```javascript
|
|
330
|
+
|
|
331
|
+
<script lang="ts" setup>
|
|
332
|
+
import { reactive, watch, ref } from 'vue'
|
|
333
|
+
|
|
334
|
+
const data = reactive({
|
|
335
|
+
val12:''
|
|
336
|
+
})
|
|
337
|
+
|
|
338
|
+
const dateRef = ref<any>()
|
|
339
|
+
const clearFunc = () => {
|
|
340
|
+
data.val11 = ''
|
|
341
|
+
dateRef.value?.hidePicker()
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
</script>
|
|
345
|
+
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
### 样式设置
|
|
350
|
+
|
|
351
|
+
通过属性`three-dimensional`可设置是否开启3D效果
|
|
352
|
+
|
|
353
|
+
```html
|
|
354
|
+
<fox-date-item v-model="data.val14" :three-dimensional="false" :visible-item-count="13">平铺</fox-date-item>
|
|
355
|
+
|
|
356
|
+
```
|
|
357
|
+
```javascript
|
|
358
|
+
|
|
359
|
+
<script lang="ts" setup>
|
|
360
|
+
import { reactive, watch, ref } from 'vue'
|
|
361
|
+
|
|
362
|
+
const data = reactive({
|
|
363
|
+
val14:''
|
|
364
|
+
})
|
|
365
|
+
|
|
366
|
+
</script>
|
|
367
|
+
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### item格式化
|
|
371
|
+
|
|
372
|
+
通过属性`dateItem-formatter`格式化picker item的格式
|
|
373
|
+
|
|
374
|
+
```html
|
|
375
|
+
<fox-date-item v-model="data.val15" :is-show-chinese="false" :item-formatter="dateItemFormatter">格式化</fox-date-item>
|
|
376
|
+
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
```javascript
|
|
380
|
+
|
|
381
|
+
<script lang="ts" setup>
|
|
382
|
+
import { reactive, watch, ref } from 'vue'
|
|
383
|
+
|
|
384
|
+
const data = reactive({
|
|
385
|
+
val15:''
|
|
386
|
+
})
|
|
387
|
+
|
|
388
|
+
// date item formatter
|
|
389
|
+
const dateItemFormatter = (option: Record<string, any>): void => {
|
|
390
|
+
if (option.type === 'year') {
|
|
391
|
+
option.text = `${option.text} 年`
|
|
392
|
+
} else if (option.type === 'month') {
|
|
393
|
+
option.text = `${option.text} 月`
|
|
394
|
+
} else if (option.type === 'day') {
|
|
395
|
+
option.text = `${option.text} 日`
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
</script>
|
|
400
|
+
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### item过滤
|
|
404
|
+
|
|
405
|
+
通过属性`dateItem-filter`可以过滤那些item可显示,返回`false`代表不显示
|
|
406
|
+
|
|
407
|
+
```html
|
|
408
|
+
<fox-date-item v-model="data.val16" :item-filter="dateItemFilter">格式化</fox-date-item>
|
|
409
|
+
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
```javascript
|
|
413
|
+
|
|
414
|
+
<script lang="ts" setup>
|
|
415
|
+
import { reactive, watch, ref } from 'vue'
|
|
416
|
+
|
|
417
|
+
const data = reactive({
|
|
418
|
+
val16:''
|
|
419
|
+
})
|
|
420
|
+
|
|
421
|
+
// date item filter(只显示偶数的年份)
|
|
422
|
+
const dateItemFilter = (option: Record<string, any>): boolean => {
|
|
423
|
+
if (option.type === 'year') {
|
|
424
|
+
return option.value % 2 === 0
|
|
425
|
+
}
|
|
426
|
+
return true
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
</script>
|
|
430
|
+
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
## 4. 相关组件 (Related Components)
|
|
434
|
+
- **fox-js**: 与 DatePicker 配合使用的相关组件
|
|
435
|
+
- **fox-date-item**: 与 DatePicker 配合使用的相关组件
|
|
436
|
+
- **fox-group**: 与 DatePicker 配合使用的相关组件
|
|
437
|
+
- **fox-button**: 与 DatePicker 配合使用的相关组件
|
|
438
|
+
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: 江成
|
|
3
|
+
* @Date: 2026-04-27 00:37:28
|
|
4
|
+
* @LastEditors: 江成
|
|
5
|
+
* @LastEditTime: 2026-05-12 22:33:21
|
|
6
|
+
-->
|
|
7
|
+
---
|
|
8
|
+
title: Dialog 组件使用规范
|
|
9
|
+
impact: HIGH
|
|
10
|
+
type: capability
|
|
11
|
+
description: 模态对话框,在浮层中显示,引导用户进行相关操作,支持图片对话框。
|
|
12
|
+
tags: [foxui, fox-dialog, FoxDialog]
|
|
13
|
+
version: "4.0.0"
|
|
14
|
+
author: jiangcheng
|
|
15
|
+
related: ["fox-js","fox-cell-group","fox-cell"]
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Dialog 组件使用规范
|
|
19
|
+
|
|
20
|
+
## 1. 核心职责 (Core Responsibility)
|
|
21
|
+
Dialog 是 foxui 中用于 **模态对话框,在浮层中显示,引导用户进行相关操作,支持图片对话框。** 的标准组件。
|
|
22
|
+
- **基于**: NutUI `nut-dialog` 进行了二次封装 (若为纯自研组件则填 "自定义开发")
|
|
23
|
+
- **核心增强**: 基于 NutUI 组件二次封装、支持 v-model 双向绑定、适配 H5 与小程序多端、支持插槽扩展自定义内容
|
|
24
|
+
- **适用场景**: 模态对话框,在浮层中显示,引导用户进行相关操作,支持图片对话框。
|
|
25
|
+
|
|
26
|
+
> 💡 **关键原则**: 在所有 模态对话框,在浮层中显示,引导用户进行相关操作,支持图片对话框。 中,**必须**优先使用此组件,禁止直接使用原生 NutUI 组件。
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 2. 关键 API 说明 (Key API)
|
|
31
|
+
|
|
32
|
+
### 2.1 Props 属性
|
|
33
|
+
|
|
34
|
+
| 属性名 | 类型 | 必填 | 默认值 | 说明 |
|
|
35
|
+
| :--- | :--- | :---: | :---: | :--- |
|
|
36
|
+
无
|
|
37
|
+
|
|
38
|
+
### 2.2 Events 事件
|
|
39
|
+
|
|
40
|
+
| 事件名 | 类型 | 说明 |
|
|
41
|
+
| :--- | :--- | :--- |
|
|
42
|
+
| `confirm` | 确定按钮回调 | Function |
|
|
43
|
+
| `cancel` | 取消按钮回调 | Function |
|
|
44
|
+
| `closed` | 关闭弹框回调 | Function |
|
|
45
|
+
| `opened` | 打开弹框回调 | Function |
|
|
46
|
+
|
|
47
|
+
### 2.3 Methods 方法
|
|
48
|
+
|
|
49
|
+
| 方法名 | 参数 | 说明 |
|
|
50
|
+
| :--- | :--- | :--- |
|
|
51
|
+
无
|
|
52
|
+
|
|
53
|
+
### 2.4 Slots 插槽
|
|
54
|
+
|
|
55
|
+
| 插槽名 | 说明 |
|
|
56
|
+
| :--- | :--- |
|
|
57
|
+
| `header` | 自定义标题区域 |
|
|
58
|
+
| `default` | 自定义内容 |
|
|
59
|
+
| `footer` | 自定义底部按钮区域 |
|
|
60
|
+
|
|
61
|
+
## 3. 例子 (Examples)
|
|
62
|
+
|
|
63
|
+
## 代码演示
|
|
64
|
+
|
|
65
|
+
### 函数调用(小程序模式暂不支持)
|
|
66
|
+
```html
|
|
67
|
+
<template>
|
|
68
|
+
<fox-cell-group title="函数式调用">
|
|
69
|
+
<fox-cell title="基础弹框" @click="baseClick"></fox-cell>
|
|
70
|
+
<fox-cell title="透明弹框" @click="transparentClick"></fox-cell>
|
|
71
|
+
<fox-cell title="支持富文本 html" @click="htmlClick"></fox-cell>
|
|
72
|
+
<fox-cell title="异步关闭" @click="beforeCloseClick"></fox-cell>
|
|
73
|
+
<fox-cell title="无标题弹框" @click="noTitleClick"></fox-cell>
|
|
74
|
+
<fox-cell title="提示弹框" @click="tipsClick"></fox-cell>
|
|
75
|
+
<fox-cell title="底部按钮 垂直调用" @click="verticalClick"></fox-cell>
|
|
76
|
+
</fox-cell-group>
|
|
77
|
+
</template>
|
|
78
|
+
<script lang="ts">
|
|
79
|
+
import { ref,createVNode } from 'vue';
|
|
80
|
+
import { Dialog } from '@nutui/nutui';
|
|
81
|
+
export default {
|
|
82
|
+
setup() {
|
|
83
|
+
const onCancel = () => {
|
|
84
|
+
console.log('event cancel');
|
|
85
|
+
};
|
|
86
|
+
const onConfirm = () => {
|
|
87
|
+
console.log('event confirm');
|
|
88
|
+
};
|
|
89
|
+
const baseClick = (): void => {
|
|
90
|
+
Dialog({
|
|
91
|
+
title: '基础弹框',
|
|
92
|
+
content: createVNode('span', { style: { color: 'red' } }, '我可以是一个自定义组件'),
|
|
93
|
+
onCancel,
|
|
94
|
+
onConfirm
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const transparentClick = (): void => {
|
|
98
|
+
Dialog({
|
|
99
|
+
overlayStyle: { background: 'rgba(0,0,0,0)' },
|
|
100
|
+
title: '透明弹框',
|
|
101
|
+
content: 'Content',
|
|
102
|
+
onCancel,
|
|
103
|
+
onConfirm
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
const htmlClick = (): void => {
|
|
107
|
+
Dialog({
|
|
108
|
+
title: "支持富文本 html",
|
|
109
|
+
content:
|
|
110
|
+
"<p style='color:red'>html</p><img src='./demo/img/hotsell.gif' />",
|
|
111
|
+
onCancel,
|
|
112
|
+
onConfirm
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
const beforeCloseClick = (): void => {
|
|
116
|
+
Dialog({
|
|
117
|
+
title: '异步关闭',
|
|
118
|
+
content: '点击确认后,1秒后关闭',
|
|
119
|
+
onCancel,
|
|
120
|
+
onConfirm,
|
|
121
|
+
beforeClose: (action: string) => {
|
|
122
|
+
return new Promise((r) => {
|
|
123
|
+
setTimeout(() => {
|
|
124
|
+
r(action == 'confirm');
|
|
125
|
+
}, 1000);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
const noTitleClick = () => {
|
|
131
|
+
Dialog({
|
|
132
|
+
content: '无标题弹框',
|
|
133
|
+
onCancel,
|
|
134
|
+
onConfirm
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
const tipsClick = () => {
|
|
138
|
+
Dialog({
|
|
139
|
+
title: '温馨提示',
|
|
140
|
+
content: '支持函数调用和组件调用两种方式。',
|
|
141
|
+
noCancelBtn: true,
|
|
142
|
+
onCancel,
|
|
143
|
+
onConfirm
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
const verticalClick = () => {
|
|
147
|
+
Dialog({
|
|
148
|
+
title: '温馨提示',
|
|
149
|
+
content: '支持底部按钮纵向排列。',
|
|
150
|
+
footerDirection: 'vertical',
|
|
151
|
+
onCancel,
|
|
152
|
+
onConfirm
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
return {
|
|
156
|
+
baseClick,
|
|
157
|
+
transparentClick,
|
|
158
|
+
htmlClick,
|
|
159
|
+
beforeCloseClick,
|
|
160
|
+
noTitleClick,
|
|
161
|
+
tipsClick,
|
|
162
|
+
verticalClick
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
</script>
|
|
167
|
+
```
|
|
168
|
+
## teleport 使用,挂载到指定节点
|
|
169
|
+
``` html
|
|
170
|
+
<fox-dialog teleport="#app" ... />
|
|
171
|
+
```
|
|
172
|
+
``` javascript
|
|
173
|
+
Dialog({
|
|
174
|
+
teleport: '#app',
|
|
175
|
+
...
|
|
176
|
+
});
|
|
177
|
+
Dialog({
|
|
178
|
+
teleport: '.demo',
|
|
179
|
+
...
|
|
180
|
+
});
|
|
181
|
+
```
|
|
182
|
+
### 函数调用 proxy.&dialog(...)
|
|
183
|
+
```javascript
|
|
184
|
+
import { ref } from 'vue';
|
|
185
|
+
import { Dialog } from '@nutui/nutui';
|
|
186
|
+
import { getCurrentInstance } from 'vue';
|
|
187
|
+
export default {
|
|
188
|
+
setup() {
|
|
189
|
+
const { proxy } = getCurrentInstance();
|
|
190
|
+
proxy.$dialog({
|
|
191
|
+
title: '基础弹框',
|
|
192
|
+
content: '支持函数调用和组件调用两种方式。'
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
### 标签式组件使用
|
|
198
|
+
```html
|
|
199
|
+
<template>
|
|
200
|
+
<fox-cell-group title="标签式使用">
|
|
201
|
+
<fox-cell title="组件调用" @click="componentClick"></fox-cell>
|
|
202
|
+
<fox-dialog
|
|
203
|
+
teleport="#app"
|
|
204
|
+
title="组件调用"
|
|
205
|
+
content="如果需要在弹窗内嵌入组件或其他自定义内容,可以使用组件调用的方式。"
|
|
206
|
+
v-model:visible="visible"
|
|
207
|
+
>
|
|
208
|
+
</fox-dialog>
|
|
209
|
+
<fox-cell title="底部按钮 垂直使用" @click="componentvVrticalClick"></fox-cell>
|
|
210
|
+
<fox-dialog
|
|
211
|
+
footer-direction="vertical"
|
|
212
|
+
teleport="#app"
|
|
213
|
+
title="组件调用"
|
|
214
|
+
content="如果需要在弹窗内嵌入组件或其他自定义内容,可以使用组件调用的方式。"
|
|
215
|
+
v-model:visible="visible1"
|
|
216
|
+
>
|
|
217
|
+
</fox-dialog>
|
|
218
|
+
</fox-cell-group>
|
|
219
|
+
</template>
|
|
220
|
+
<script lang="ts">
|
|
221
|
+
import { ref } from 'vue';
|
|
222
|
+
export default {
|
|
223
|
+
setup() {
|
|
224
|
+
const visible = ref(false);
|
|
225
|
+
const visible1 = ref(false);
|
|
226
|
+
const componentClick = () => {
|
|
227
|
+
visible.value = true;
|
|
228
|
+
};
|
|
229
|
+
const componentvVrticalClick = () => {
|
|
230
|
+
visible1.value = true;
|
|
231
|
+
};
|
|
232
|
+
return { visible,visible1,componentClick,componentvVrticalClick };
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
</script>
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## 4. 相关组件 (Related Components)
|
|
239
|
+
- **fox-js**: 与 Dialog 配合使用的相关组件
|
|
240
|
+
- **fox-cell-group**: 与 Dialog 配合使用的相关组件
|
|
241
|
+
- **fox-cell**: 与 Dialog 配合使用的相关组件
|
|
242
|
+
|