@ebiz/designer-components 0.0.18 → 0.0.19
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/package.json +3 -2
- package/src/apiService/mockDataService.js +116 -0
- package/src/apiService/simpleDataService.js +186 -80
- package/src/components/Button.vue +72 -22
- package/src/components/EbizAvatar.vue +116 -0
- package/src/components/EbizCheckbox.vue +94 -0
- package/src/components/EbizCheckboxGroup.vue +70 -0
- package/src/components/EbizDetailBlock.vue +82 -0
- package/src/components/EbizDialog.vue +244 -56
- package/src/components/EbizEmployeeInfo.vue +139 -0
- package/src/components/EbizFileUpload.vue +202 -0
- package/src/components/EbizPageHeader.vue +96 -0
- package/src/components/EbizPagination.vue +163 -0
- package/src/components/EbizRadio.vue +87 -0
- package/src/components/EbizRadioGroup.vue +84 -0
- package/src/components/EbizRemoteSelect.vue +118 -40
- package/src/components/EbizSpace.vue +101 -0
- package/src/components/EbizStatistic.vue +150 -0
- package/src/components/EbizSwiper.vue +114 -0
- package/src/components/EbizSwiperItem.vue +14 -0
- package/src/components/EbizSwitch.vue +86 -0
- package/src/components/EbizTabHeader.vue +145 -0
- package/src/components/EbizTabPanel.vue +23 -0
- package/src/components/EbizTable.vue +466 -0
- package/src/components/EbizTableColumn.vue +117 -0
- package/src/components/EbizTableSort.vue +181 -0
- package/src/components/EbizTabs.vue +133 -91
- package/src/components/EbizTimePicker.vue +144 -0
- package/src/components/EbizTitle.vue +3 -10
- package/src/components/EbizTree.vue +153 -0
- package/src/components/EbizTreeSelector.vue +423 -0
- package/src/components/Home.vue +8 -0
- package/src/components/TdesignAlert.vue +116 -0
- package/src/components/TdesignButton.vue +130 -0
- package/src/components/TdesignCalendar/index.vue +146 -0
- package/src/components/TdesignCard.vue +196 -0
- package/src/components/TdesignCol.vue +102 -0
- package/src/components/TdesignCollapse.vue +143 -0
- package/src/components/TdesignCollapsePanel.vue +80 -0
- package/src/components/TdesignDatePicker.vue +125 -0
- package/src/components/TdesignDialog.vue +226 -0
- package/src/components/TdesignForm.vue +134 -0
- package/src/components/TdesignFormItem.vue +106 -0
- package/src/components/TdesignGrid.vue +56 -0
- package/src/components/TdesignIcon.vue +68 -0
- package/src/components/TdesignImage.vue +163 -0
- package/src/components/TdesignImageViewer.vue +201 -0
- package/src/components/TdesignInput.vue +243 -0
- package/src/components/TdesignSelect.vue +445 -0
- package/src/components/TdesignTag.vue +118 -0
- package/src/components/TdesignTextarea.vue +143 -0
- package/src/components/TdesignTimeline.vue +58 -0
- package/src/components/TdesignTimelineItem.vue +72 -0
- package/src/components/TdesignUpload.vue +757 -0
- package/src/components/TdesignWatermark.vue +108 -0
- package/src/index.js +130 -0
- package/src/main.js +20 -4
- package/src/router/index.js +244 -5
- package/src/views/Button.vue +7 -3
- package/src/views/CheckboxDemo.vue +105 -0
- package/src/views/DialogDemo.vue +126 -0
- package/src/views/EbizAvatar.vue +224 -0
- package/src/views/EbizDetailBlockDemo.vue +31 -0
- package/src/views/EbizEmployeeInfo.vue +250 -0
- package/src/views/EbizRadioDemo.vue +152 -0
- package/src/views/EbizSpace.vue +186 -0
- package/src/views/EbizSwiper.vue +158 -0
- package/src/views/GridDemo.vue +239 -0
- package/src/views/Home.vue +63 -2
- package/src/views/PageHeaderDemo.vue +105 -0
- package/src/views/PaginationDemo.vue +97 -0
- package/src/views/RemoteSelect.vue +336 -5
- package/src/views/StatisticDemo.vue +191 -0
- package/src/views/SwitchDemo.vue +80 -0
- package/src/views/TableDemo.vue +335 -0
- package/src/views/TableSortDemo.vue +144 -0
- package/src/views/TableView.vue +69 -0
- package/src/views/TabsDemo.vue +283 -0
- package/src/views/TagDemo.vue +102 -0
- package/src/views/TdesignAlert.vue +99 -0
- package/src/views/TdesignButton.vue +191 -0
- package/src/views/TdesignCalendar.vue +95 -0
- package/src/views/TdesignCard.vue +297 -0
- package/src/views/TdesignCollapse.vue +294 -0
- package/src/views/TdesignDatePicker.vue +188 -0
- package/src/views/TdesignForm.vue +249 -0
- package/src/views/TdesignIcon.vue +204 -0
- package/src/views/TdesignImage.vue +216 -0
- package/src/views/TdesignImageViewer.vue +199 -0
- package/src/views/TdesignInput.vue +253 -0
- package/src/views/TdesignSelect.vue +474 -0
- package/src/views/TdesignSwiper.vue +158 -0
- package/src/views/TextareaDemo.vue +94 -0
- package/src/views/TimePickerDemo.vue +147 -0
- package/src/views/TimelineDemo.vue +161 -0
- package/src/views/TreeDemo.vue +255 -0
- package/src/views/TreeSelectorDemo.vue +246 -0
- package/src/views/UploadDemo.vue +122 -0
- package/src/views/WatermarkDemo.vue +86 -0
@@ -0,0 +1,474 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="tdesign-select-demo">
|
3
|
+
<h2>TDesign 选择器示例</h2>
|
4
|
+
|
5
|
+
<div class="section">
|
6
|
+
<h3>基础选择器</h3>
|
7
|
+
<div class="select-row">
|
8
|
+
<ebiz-tdesign-select
|
9
|
+
v-model="value1"
|
10
|
+
placeholder="请选择"
|
11
|
+
:options="baseOptions"
|
12
|
+
clearable
|
13
|
+
/>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<div class="section">
|
18
|
+
<h3>多选选择器</h3>
|
19
|
+
<div class="select-row">
|
20
|
+
<ebiz-tdesign-select
|
21
|
+
v-model="value2"
|
22
|
+
placeholder="请选择多项"
|
23
|
+
:options="baseOptions"
|
24
|
+
multiple
|
25
|
+
clearable
|
26
|
+
/>
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
|
30
|
+
<div class="section">
|
31
|
+
<h3>可搜索选择器</h3>
|
32
|
+
<div class="select-row">
|
33
|
+
<ebiz-tdesign-select
|
34
|
+
v-model="value3"
|
35
|
+
placeholder="请输入搜索"
|
36
|
+
:options="baseOptions"
|
37
|
+
filterable
|
38
|
+
clearable
|
39
|
+
/>
|
40
|
+
</div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div class="section">
|
44
|
+
<h3>带标签的选择器</h3>
|
45
|
+
<div class="select-row">
|
46
|
+
<ebiz-tdesign-select
|
47
|
+
v-model="valueWithLabel"
|
48
|
+
label="选择器:"
|
49
|
+
placeholder="带标签的选择器"
|
50
|
+
:options="baseOptions"
|
51
|
+
clearable
|
52
|
+
/>
|
53
|
+
</div>
|
54
|
+
</div>
|
55
|
+
|
56
|
+
<div class="section">
|
57
|
+
<h3>自定义键名选择器</h3>
|
58
|
+
<div class="select-row">
|
59
|
+
<ebiz-tdesign-select
|
60
|
+
v-model="valueWithKeys"
|
61
|
+
placeholder="自定义键名选择器"
|
62
|
+
:options="customKeyOptions"
|
63
|
+
:keys="{label: 'text', value: 'id'}"
|
64
|
+
clearable
|
65
|
+
/>
|
66
|
+
</div>
|
67
|
+
</div>
|
68
|
+
|
69
|
+
<div class="section">
|
70
|
+
<h3>尺寸变体</h3>
|
71
|
+
<div class="select-row">
|
72
|
+
<ebiz-tdesign-select
|
73
|
+
v-model="value4Small"
|
74
|
+
placeholder="小尺寸"
|
75
|
+
:options="baseOptions"
|
76
|
+
size="small"
|
77
|
+
clearable
|
78
|
+
/>
|
79
|
+
<ebiz-tdesign-select
|
80
|
+
v-model="value4Medium"
|
81
|
+
placeholder="中尺寸"
|
82
|
+
:options="baseOptions"
|
83
|
+
size="medium"
|
84
|
+
clearable
|
85
|
+
/>
|
86
|
+
<ebiz-tdesign-select
|
87
|
+
v-model="value4Large"
|
88
|
+
placeholder="大尺寸"
|
89
|
+
:options="baseOptions"
|
90
|
+
size="large"
|
91
|
+
clearable
|
92
|
+
/>
|
93
|
+
</div>
|
94
|
+
</div>
|
95
|
+
|
96
|
+
<div class="section">
|
97
|
+
<h3>无边框选择器</h3>
|
98
|
+
<div class="select-row">
|
99
|
+
<ebiz-tdesign-select
|
100
|
+
v-model="value5"
|
101
|
+
placeholder="无边框样式"
|
102
|
+
:options="baseOptions"
|
103
|
+
borderless
|
104
|
+
clearable
|
105
|
+
/>
|
106
|
+
</div>
|
107
|
+
</div>
|
108
|
+
|
109
|
+
<div class="section">
|
110
|
+
<h3>状态变体</h3>
|
111
|
+
<div class="select-row">
|
112
|
+
<ebiz-tdesign-select
|
113
|
+
v-model="value6Success"
|
114
|
+
placeholder="成功状态"
|
115
|
+
:options="baseOptions"
|
116
|
+
status="success"
|
117
|
+
tips="成功的提示信息"
|
118
|
+
clearable
|
119
|
+
/>
|
120
|
+
<ebiz-tdesign-select
|
121
|
+
v-model="value6Warning"
|
122
|
+
placeholder="警告状态"
|
123
|
+
:options="baseOptions"
|
124
|
+
status="warning"
|
125
|
+
tips="警告的提示信息"
|
126
|
+
clearable
|
127
|
+
/>
|
128
|
+
<ebiz-tdesign-select
|
129
|
+
v-model="value6Error"
|
130
|
+
placeholder="错误状态"
|
131
|
+
:options="baseOptions"
|
132
|
+
status="error"
|
133
|
+
tips="错误的提示信息"
|
134
|
+
clearable
|
135
|
+
/>
|
136
|
+
</div>
|
137
|
+
</div>
|
138
|
+
|
139
|
+
<div class="section">
|
140
|
+
<h3>特殊状态</h3>
|
141
|
+
<div class="select-row">
|
142
|
+
<ebiz-tdesign-select
|
143
|
+
v-model="value7Disabled"
|
144
|
+
placeholder="禁用状态"
|
145
|
+
:options="baseOptions"
|
146
|
+
disabled
|
147
|
+
/>
|
148
|
+
<ebiz-tdesign-select
|
149
|
+
v-model="value7Loading"
|
150
|
+
placeholder="加载状态"
|
151
|
+
:options="baseOptions"
|
152
|
+
loading
|
153
|
+
loadingText="加载中..."
|
154
|
+
/>
|
155
|
+
<ebiz-tdesign-select
|
156
|
+
v-model="value7Readonly"
|
157
|
+
placeholder="只读状态"
|
158
|
+
:options="baseOptions"
|
159
|
+
readonly
|
160
|
+
/>
|
161
|
+
</div>
|
162
|
+
</div>
|
163
|
+
|
164
|
+
<div class="section">
|
165
|
+
<h3>自适应宽度</h3>
|
166
|
+
<div class="select-row">
|
167
|
+
<ebiz-tdesign-select
|
168
|
+
v-model="value8"
|
169
|
+
placeholder="宽度自适应"
|
170
|
+
:options="baseOptions"
|
171
|
+
autoWidth
|
172
|
+
clearable
|
173
|
+
/>
|
174
|
+
</div>
|
175
|
+
</div>
|
176
|
+
|
177
|
+
<div class="section">
|
178
|
+
<h3>可创建选项</h3>
|
179
|
+
<div class="select-row">
|
180
|
+
<ebiz-tdesign-select
|
181
|
+
v-model="value9"
|
182
|
+
placeholder="输入创建新选项"
|
183
|
+
:options="baseOptions"
|
184
|
+
creatable
|
185
|
+
filterable
|
186
|
+
clearable
|
187
|
+
@create="handleCreate"
|
188
|
+
/>
|
189
|
+
</div>
|
190
|
+
</div>
|
191
|
+
|
192
|
+
<div class="section">
|
193
|
+
<h3>多选折叠显示</h3>
|
194
|
+
<div class="select-row">
|
195
|
+
<ebiz-tdesign-select
|
196
|
+
v-model="valueCollapsed"
|
197
|
+
placeholder="多选折叠显示"
|
198
|
+
:options="moreOptions"
|
199
|
+
multiple
|
200
|
+
:minCollapsedNum="2"
|
201
|
+
clearable
|
202
|
+
:collapsedItems="({ collapsedSelectedItems }) => `+${collapsedSelectedItems.length}`"
|
203
|
+
/>
|
204
|
+
</div>
|
205
|
+
</div>
|
206
|
+
|
207
|
+
<div class="section">
|
208
|
+
<h3>虚拟滚动</h3>
|
209
|
+
<div class="select-row">
|
210
|
+
<ebiz-tdesign-select
|
211
|
+
v-model="valueWithScroll"
|
212
|
+
placeholder="虚拟滚动(大数据量)"
|
213
|
+
:options="largeDataOptions"
|
214
|
+
:scroll="{ type: 'virtual', threshold: 100 }"
|
215
|
+
clearable
|
216
|
+
@scroll="handleVirtualScroll"
|
217
|
+
/>
|
218
|
+
</div>
|
219
|
+
</div>
|
220
|
+
|
221
|
+
<div class="section">
|
222
|
+
<h3>带前缀图标</h3>
|
223
|
+
<div class="select-row">
|
224
|
+
<ebiz-tdesign-select
|
225
|
+
v-model="valueWithIcon"
|
226
|
+
placeholder="带图标的选择器"
|
227
|
+
:options="baseOptions"
|
228
|
+
prefixIcon="search"
|
229
|
+
clearable
|
230
|
+
/>
|
231
|
+
</div>
|
232
|
+
</div>
|
233
|
+
|
234
|
+
<div class="section">
|
235
|
+
<h3>事件处理</h3>
|
236
|
+
<div class="select-row">
|
237
|
+
<ebiz-tdesign-select
|
238
|
+
v-model="value10"
|
239
|
+
placeholder="包含多种事件"
|
240
|
+
:options="baseOptions"
|
241
|
+
clearable
|
242
|
+
@change="handleChange"
|
243
|
+
@focus="handleFocus"
|
244
|
+
@blur="handleBlur"
|
245
|
+
@clear="handleClear"
|
246
|
+
@keydown="handleKeydown"
|
247
|
+
@mouseenter="handleMouseEnter"
|
248
|
+
@mouseleave="handleMouseLeave"
|
249
|
+
/>
|
250
|
+
</div>
|
251
|
+
<div class="event-log">
|
252
|
+
<p>事件日志:</p>
|
253
|
+
<div v-for="(log, index) in eventLogs" :key="index">
|
254
|
+
{{ log }}
|
255
|
+
</div>
|
256
|
+
</div>
|
257
|
+
</div>
|
258
|
+
|
259
|
+
<div class="section">
|
260
|
+
<h3>自定义选项面板</h3>
|
261
|
+
<div class="select-row">
|
262
|
+
<ebiz-tdesign-select
|
263
|
+
v-model="valueWithPanel"
|
264
|
+
placeholder="带自定义面板的选择器"
|
265
|
+
:options="baseOptions"
|
266
|
+
clearable
|
267
|
+
>
|
268
|
+
<template #panelTopContent>
|
269
|
+
<div class="custom-panel-header">自定义面板顶部内容</div>
|
270
|
+
</template>
|
271
|
+
<template #panelBottomContent>
|
272
|
+
<div class="custom-panel-footer">自定义面板底部内容</div>
|
273
|
+
</template>
|
274
|
+
</ebiz-tdesign-select>
|
275
|
+
</div>
|
276
|
+
</div>
|
277
|
+
</div>
|
278
|
+
</template>
|
279
|
+
|
280
|
+
<script>
|
281
|
+
import { EbizTdesignSelect } from '../index.js'
|
282
|
+
|
283
|
+
export default {
|
284
|
+
name: 'TdesignSelectDemo',
|
285
|
+
components: {
|
286
|
+
EbizTdesignSelect
|
287
|
+
},
|
288
|
+
data() {
|
289
|
+
return {
|
290
|
+
// 基础选项数据
|
291
|
+
baseOptions: [
|
292
|
+
{ label: '选项一', value: '1' },
|
293
|
+
{ label: '选项二', value: '2' },
|
294
|
+
{ label: '选项三', value: '3' },
|
295
|
+
{ label: '选项四', value: '4' },
|
296
|
+
{ label: '选项五', value: '5' }
|
297
|
+
],
|
298
|
+
|
299
|
+
// 自定义键名选项数据
|
300
|
+
customKeyOptions: [
|
301
|
+
{ text: '自定义选项一', id: '101' },
|
302
|
+
{ text: '自定义选项二', id: '102' },
|
303
|
+
{ text: '自定义选项三', id: '103' }
|
304
|
+
],
|
305
|
+
|
306
|
+
// 多项选项数据
|
307
|
+
moreOptions: Array.from({ length: 20 }).map((_, index) => ({
|
308
|
+
label: `选项 ${index + 1}`,
|
309
|
+
value: `${index + 1}`
|
310
|
+
})),
|
311
|
+
|
312
|
+
// 各种示例的选中值
|
313
|
+
value1: '',
|
314
|
+
value2: [],
|
315
|
+
value3: '',
|
316
|
+
value4Small: '',
|
317
|
+
value4Medium: '',
|
318
|
+
value4Large: '',
|
319
|
+
value5: '',
|
320
|
+
value6Success: '',
|
321
|
+
value6Warning: '',
|
322
|
+
value6Error: '',
|
323
|
+
value7Disabled: '',
|
324
|
+
value7Loading: '',
|
325
|
+
value7Readonly: '1',
|
326
|
+
value8: '',
|
327
|
+
value9: '',
|
328
|
+
value10: '',
|
329
|
+
valueWithLabel: '',
|
330
|
+
valueWithKeys: '',
|
331
|
+
valueCollapsed: [],
|
332
|
+
valueWithPanel: '',
|
333
|
+
valueWithIcon: '',
|
334
|
+
valueWithScroll: '',
|
335
|
+
|
336
|
+
// 事件日志
|
337
|
+
eventLogs: [],
|
338
|
+
|
339
|
+
// 大数据选项
|
340
|
+
largeDataOptions: Array.from({ length: 5000 }).map((_, index) => ({
|
341
|
+
label: `大数据选项 ${index + 1}`,
|
342
|
+
value: `large-${index + 1}`
|
343
|
+
}))
|
344
|
+
}
|
345
|
+
},
|
346
|
+
methods: {
|
347
|
+
// 创建新选项
|
348
|
+
handleCreate(value) {
|
349
|
+
this.baseOptions.push({
|
350
|
+
label: value,
|
351
|
+
value: `new-${this.baseOptions.length + 1}`
|
352
|
+
});
|
353
|
+
this.addEventLog(`创建了新选项: ${value}`);
|
354
|
+
},
|
355
|
+
|
356
|
+
// 选中值变化
|
357
|
+
handleChange(value, context) {
|
358
|
+
this.addEventLog(`选中值变化: ${value}`);
|
359
|
+
},
|
360
|
+
|
361
|
+
// 获得焦点
|
362
|
+
handleFocus(context) {
|
363
|
+
this.addEventLog('选择器获得焦点');
|
364
|
+
},
|
365
|
+
|
366
|
+
// 失去焦点
|
367
|
+
handleBlur(value, context) {
|
368
|
+
this.addEventLog('选择器失去焦点');
|
369
|
+
},
|
370
|
+
|
371
|
+
// 清空选项
|
372
|
+
handleClear(context) {
|
373
|
+
this.addEventLog('选择器被清空');
|
374
|
+
},
|
375
|
+
|
376
|
+
// 键盘按下
|
377
|
+
handleKeydown(value, context) {
|
378
|
+
this.addEventLog(`键盘按下: ${value.key}`);
|
379
|
+
},
|
380
|
+
|
381
|
+
// 鼠标进入
|
382
|
+
handleMouseEnter(context) {
|
383
|
+
this.addEventLog('鼠标进入选择器');
|
384
|
+
},
|
385
|
+
|
386
|
+
// 鼠标离开
|
387
|
+
handleMouseLeave(context) {
|
388
|
+
this.addEventLog('鼠标离开选择器');
|
389
|
+
},
|
390
|
+
|
391
|
+
// 虚拟滚动事件
|
392
|
+
handleVirtualScroll({ scrollTop, scrollBottom }) {
|
393
|
+
this.addEventLog(`滚动位置: 顶部${scrollTop}px, 底部${scrollBottom}px`);
|
394
|
+
},
|
395
|
+
|
396
|
+
// 添加事件日志
|
397
|
+
addEventLog(log) {
|
398
|
+
const now = new Date();
|
399
|
+
const time = `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}:${now.getSeconds().toString().padStart(2, '0')}`;
|
400
|
+
this.eventLogs.unshift(`[${time}] ${log}`);
|
401
|
+
|
402
|
+
// 只保留最近10条日志
|
403
|
+
if (this.eventLogs.length > 10) {
|
404
|
+
this.eventLogs = this.eventLogs.slice(0, 10);
|
405
|
+
}
|
406
|
+
}
|
407
|
+
}
|
408
|
+
}
|
409
|
+
</script>
|
410
|
+
|
411
|
+
<style scoped>
|
412
|
+
.tdesign-select-demo {
|
413
|
+
padding: 20px;
|
414
|
+
max-width: 1200px;
|
415
|
+
margin: 0 auto;
|
416
|
+
}
|
417
|
+
|
418
|
+
.section {
|
419
|
+
margin-bottom: 30px;
|
420
|
+
border-bottom: 1px solid #eee;
|
421
|
+
padding-bottom: 20px;
|
422
|
+
}
|
423
|
+
|
424
|
+
h2 {
|
425
|
+
margin-bottom: 20px;
|
426
|
+
font-size: 24px;
|
427
|
+
color: #0052d9;
|
428
|
+
}
|
429
|
+
|
430
|
+
h3 {
|
431
|
+
margin-bottom: 12px;
|
432
|
+
font-size: 18px;
|
433
|
+
color: #333;
|
434
|
+
}
|
435
|
+
|
436
|
+
.select-row {
|
437
|
+
display: flex;
|
438
|
+
gap: 20px;
|
439
|
+
margin-bottom: 16px;
|
440
|
+
flex-wrap: wrap;
|
441
|
+
align-items: center;
|
442
|
+
}
|
443
|
+
|
444
|
+
.event-log {
|
445
|
+
margin-top: 16px;
|
446
|
+
background-color: #f5f5f5;
|
447
|
+
padding: 12px;
|
448
|
+
border-radius: 6px;
|
449
|
+
max-height: 200px;
|
450
|
+
overflow-y: auto;
|
451
|
+
font-family: monospace;
|
452
|
+
font-size: 14px;
|
453
|
+
}
|
454
|
+
|
455
|
+
.event-log p {
|
456
|
+
font-weight: bold;
|
457
|
+
margin-bottom: 8px;
|
458
|
+
}
|
459
|
+
|
460
|
+
.custom-panel-header,
|
461
|
+
.custom-panel-footer {
|
462
|
+
padding: 8px 12px;
|
463
|
+
background-color: #f0f5ff;
|
464
|
+
color: #0052d9;
|
465
|
+
text-align: center;
|
466
|
+
border-radius: 3px;
|
467
|
+
margin: 4px 0;
|
468
|
+
}
|
469
|
+
|
470
|
+
.custom-panel-footer {
|
471
|
+
background-color: #f5f5f5;
|
472
|
+
color: #666;
|
473
|
+
}
|
474
|
+
</style>
|
@@ -0,0 +1,158 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="swiper-demo">
|
3
|
+
<h1>TDesign 轮播框组件示例</h1>
|
4
|
+
|
5
|
+
<div class="demo-section">
|
6
|
+
<h2>1. 基础轮播</h2>
|
7
|
+
<ebiz-swiper>
|
8
|
+
<ebiz-swiper-item v-for="(item, index) in swiperItems" :key="index">
|
9
|
+
<div class="demo-item" :style="{ backgroundColor: item.color }">
|
10
|
+
{{ item.label }}
|
11
|
+
</div>
|
12
|
+
</ebiz-swiper-item>
|
13
|
+
</ebiz-swiper>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div class="demo-section">
|
17
|
+
<h2>2. 垂直布局</h2>
|
18
|
+
<ebiz-swiper direction="vertical" :height="200">
|
19
|
+
<ebiz-swiper-item v-for="(item, index) in swiperItems" :key="index">
|
20
|
+
<div class="demo-item" :style="{ backgroundColor: item.color }">
|
21
|
+
{{ item.label }}
|
22
|
+
</div>
|
23
|
+
</ebiz-swiper-item>
|
24
|
+
</ebiz-swiper>
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<div class="demo-section">
|
28
|
+
<h2>3. 自定义导航器位置</h2>
|
29
|
+
<ebiz-swiper :navigation="{ placement: 'outside' }">
|
30
|
+
<ebiz-swiper-item v-for="(item, index) in swiperItems" :key="index">
|
31
|
+
<div class="demo-item" :style="{ backgroundColor: item.color }">
|
32
|
+
{{ item.label }}
|
33
|
+
</div>
|
34
|
+
</ebiz-swiper-item>
|
35
|
+
</ebiz-swiper>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<div class="demo-section">
|
39
|
+
<h2>4. 分式导航器</h2>
|
40
|
+
<ebiz-swiper :navigation="{ type: 'fraction' }">
|
41
|
+
<ebiz-swiper-item v-for="(item, index) in swiperItems" :key="index">
|
42
|
+
<div class="demo-item" :style="{ backgroundColor: item.color }">
|
43
|
+
{{ item.label }}
|
44
|
+
</div>
|
45
|
+
</ebiz-swiper-item>
|
46
|
+
</ebiz-swiper>
|
47
|
+
</div>
|
48
|
+
|
49
|
+
<div class="demo-section">
|
50
|
+
<h2>5. 渐隐模式</h2>
|
51
|
+
<ebiz-swiper animation="fade">
|
52
|
+
<ebiz-swiper-item v-for="(item, index) in swiperItems" :key="index">
|
53
|
+
<div class="demo-item" :style="{ backgroundColor: item.color }">
|
54
|
+
{{ item.label }}
|
55
|
+
</div>
|
56
|
+
</ebiz-swiper-item>
|
57
|
+
</ebiz-swiper>
|
58
|
+
</div>
|
59
|
+
|
60
|
+
<div class="demo-section">
|
61
|
+
<h2>6. 手动控制</h2>
|
62
|
+
<div class="control-panel">
|
63
|
+
<t-button @click="currentIndex = (currentIndex - 1 + swiperItems.length) % swiperItems.length">上一张</t-button>
|
64
|
+
<t-button @click="currentIndex = (currentIndex + 1) % swiperItems.length">下一张</t-button>
|
65
|
+
</div>
|
66
|
+
<ebiz-swiper v-model:current="currentIndex" :autoplay="false">
|
67
|
+
<ebiz-swiper-item v-for="(item, index) in swiperItems" :key="index">
|
68
|
+
<div class="demo-item" :style="{ backgroundColor: item.color }">
|
69
|
+
{{ item.label }}
|
70
|
+
</div>
|
71
|
+
</ebiz-swiper-item>
|
72
|
+
</ebiz-swiper>
|
73
|
+
</div>
|
74
|
+
|
75
|
+
<div class="demo-section">
|
76
|
+
<h2>7. 自定义导航器大小</h2>
|
77
|
+
<ebiz-swiper :navigation="{ size: 'large' }">
|
78
|
+
<ebiz-swiper-item v-for="(item, index) in swiperItems" :key="index">
|
79
|
+
<div class="demo-item" :style="{ backgroundColor: item.color }">
|
80
|
+
{{ item.label }}
|
81
|
+
</div>
|
82
|
+
</ebiz-swiper-item>
|
83
|
+
</ebiz-swiper>
|
84
|
+
</div>
|
85
|
+
</div>
|
86
|
+
</template>
|
87
|
+
|
88
|
+
<script>
|
89
|
+
import { ref } from 'vue';
|
90
|
+
import { EbizSwiper, EbizSwiperItem } from '../index.js';
|
91
|
+
import { Button as TButton } from 'tdesign-vue-next';
|
92
|
+
|
93
|
+
export default {
|
94
|
+
name: 'TdesignSwiperDemo',
|
95
|
+
components: {
|
96
|
+
EbizSwiper,
|
97
|
+
EbizSwiperItem,
|
98
|
+
TButton
|
99
|
+
},
|
100
|
+
setup() {
|
101
|
+
const currentIndex = ref(0);
|
102
|
+
|
103
|
+
const swiperItems = [
|
104
|
+
{ label: '1', color: '#0052D9' },
|
105
|
+
{ label: '2', color: '#0594FA' },
|
106
|
+
{ label: '3', color: '#05A573' },
|
107
|
+
{ label: '4', color: '#D54941' },
|
108
|
+
{ label: '5', color: '#ED7B2F' },
|
109
|
+
{ label: '6', color: '#9B38D3' }
|
110
|
+
];
|
111
|
+
|
112
|
+
return {
|
113
|
+
currentIndex,
|
114
|
+
swiperItems
|
115
|
+
};
|
116
|
+
}
|
117
|
+
};
|
118
|
+
</script>
|
119
|
+
|
120
|
+
<style scoped>
|
121
|
+
.swiper-demo {
|
122
|
+
padding: 20px;
|
123
|
+
}
|
124
|
+
|
125
|
+
.demo-section {
|
126
|
+
margin-bottom: 40px;
|
127
|
+
border: 1px solid #eaeaea;
|
128
|
+
border-radius: 8px;
|
129
|
+
padding: 20px;
|
130
|
+
}
|
131
|
+
|
132
|
+
h1 {
|
133
|
+
margin-bottom: 30px;
|
134
|
+
color: #333;
|
135
|
+
}
|
136
|
+
|
137
|
+
h2 {
|
138
|
+
margin-bottom: 15px;
|
139
|
+
color: #666;
|
140
|
+
font-size: 18px;
|
141
|
+
}
|
142
|
+
|
143
|
+
.demo-item {
|
144
|
+
display: flex;
|
145
|
+
align-items: center;
|
146
|
+
justify-content: center;
|
147
|
+
height: 200px;
|
148
|
+
color: white;
|
149
|
+
font-size: 32px;
|
150
|
+
font-weight: bold;
|
151
|
+
}
|
152
|
+
|
153
|
+
.control-panel {
|
154
|
+
display: flex;
|
155
|
+
gap: 10px;
|
156
|
+
margin-bottom: 10px;
|
157
|
+
}
|
158
|
+
</style>
|