uniapp-dyckui 4.1.1

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.
Files changed (80) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +104 -0
  3. package/dist/assets/style.BFlsbpSj.css +1472 -0
  4. package/dist/index.cjs.js +1380 -0
  5. package/dist/index.cjs.js.map +1 -0
  6. package/dist/index.es.js +1380 -0
  7. package/dist/index.es.js.map +1 -0
  8. package/dist/src/components/MyComs/Button/index.d.ts +3 -0
  9. package/dist/src/components/MyComs/Button/index.vue.d.ts +93 -0
  10. package/dist/src/components/MyComs/Dialog/index.d.ts +3 -0
  11. package/dist/src/components/MyComs/Dialog/index.vue.d.ts +65 -0
  12. package/dist/src/components/MyComs/Divider/index.d.ts +3 -0
  13. package/dist/src/components/MyComs/Divider/index.vue.d.ts +53 -0
  14. package/dist/src/components/MyComs/DropdownSelect/dropdownSelect.d.ts +10 -0
  15. package/dist/src/components/MyComs/DropdownSelect/index.d.ts +4 -0
  16. package/dist/src/components/MyComs/DropdownSelect/index.vue.d.ts +26 -0
  17. package/dist/src/components/MyComs/DropdownSelect/type.d.ts +13 -0
  18. package/dist/src/components/MyComs/DropdownWithBadge/dropdownWithBadge.d.ts +5 -0
  19. package/dist/src/components/MyComs/DropdownWithBadge/index.d.ts +4 -0
  20. package/dist/src/components/MyComs/DropdownWithBadge/index.vue.d.ts +26 -0
  21. package/dist/src/components/MyComs/DropdownWithBadge/type.d.ts +9 -0
  22. package/dist/src/components/MyComs/FilterDrawer/hasBadge.d.ts +8 -0
  23. package/dist/src/components/MyComs/FilterDrawer/index.d.ts +5 -0
  24. package/dist/src/components/MyComs/FilterDrawer/index.vue.d.ts +26 -0
  25. package/dist/src/components/MyComs/FilterDrawer/type.d.ts +8 -0
  26. package/dist/src/components/MyComs/FilterDrawer/useFilterDrawer.d.ts +10 -0
  27. package/dist/src/components/MyComs/InfiniteScroll/index.d.ts +3 -0
  28. package/dist/src/components/MyComs/InfiniteScroll/index.vue.d.ts +65 -0
  29. package/dist/src/components/MyComs/Popup/index.d.ts +3 -0
  30. package/dist/src/components/MyComs/Popup/index.vue.d.ts +119 -0
  31. package/dist/src/components/MyComs/PullRefresh/index.d.ts +3 -0
  32. package/dist/src/components/MyComs/PullRefresh/index.vue.d.ts +117 -0
  33. package/dist/src/components/MyComs/Swiper/index.d.ts +3 -0
  34. package/dist/src/components/MyComs/Swiper/index.vue.d.ts +79 -0
  35. package/dist/src/components/MyComs/Toast/index.d.ts +3 -0
  36. package/dist/src/components/MyComs/Toast/index.vue.d.ts +108 -0
  37. package/dist/src/components/MyComs/index.d.ts +20 -0
  38. package/package.json +218 -0
  39. package/src/components/MyComs/Button/README.md +235 -0
  40. package/src/components/MyComs/Button/index.ts +3 -0
  41. package/src/components/MyComs/Button/index.vue +413 -0
  42. package/src/components/MyComs/Dialog/README.md +160 -0
  43. package/src/components/MyComs/Dialog/index.ts +2 -0
  44. package/src/components/MyComs/Dialog/index.vue +275 -0
  45. package/src/components/MyComs/Divider/README.md +0 -0
  46. package/src/components/MyComs/Divider/index.ts +2 -0
  47. package/src/components/MyComs/Divider/index.vue +106 -0
  48. package/src/components/MyComs/DropdownSelect/README.md +112 -0
  49. package/src/components/MyComs/DropdownSelect/dropdownSelect.less +75 -0
  50. package/src/components/MyComs/DropdownSelect/dropdownSelect.ts +59 -0
  51. package/src/components/MyComs/DropdownSelect/index.ts +4 -0
  52. package/src/components/MyComs/DropdownSelect/index.vue +88 -0
  53. package/src/components/MyComs/DropdownSelect/type.ts +15 -0
  54. package/src/components/MyComs/DropdownWithBadge/README.md +77 -0
  55. package/src/components/MyComs/DropdownWithBadge/dropdownWithBadge.less +11 -0
  56. package/src/components/MyComs/DropdownWithBadge/dropdownWithBadge.ts +10 -0
  57. package/src/components/MyComs/DropdownWithBadge/index.ts +4 -0
  58. package/src/components/MyComs/DropdownWithBadge/index.vue +39 -0
  59. package/src/components/MyComs/DropdownWithBadge/type.ts +12 -0
  60. package/src/components/MyComs/FilterDrawer/filterDrawer.less +117 -0
  61. package/src/components/MyComs/FilterDrawer/hasBadge.ts +41 -0
  62. package/src/components/MyComs/FilterDrawer/index.ts +5 -0
  63. package/src/components/MyComs/FilterDrawer/index.vue +53 -0
  64. package/src/components/MyComs/FilterDrawer/type.ts +9 -0
  65. package/src/components/MyComs/FilterDrawer/useFilterDrawer.ts +38 -0
  66. package/src/components/MyComs/InfiniteScroll/index.ts +2 -0
  67. package/src/components/MyComs/InfiniteScroll/index.vue +171 -0
  68. package/src/components/MyComs/Popup/README.md +684 -0
  69. package/src/components/MyComs/Popup/index.ts +2 -0
  70. package/src/components/MyComs/Popup/index.vue +835 -0
  71. package/src/components/MyComs/PullRefresh/README.md +600 -0
  72. package/src/components/MyComs/PullRefresh/index.ts +2 -0
  73. package/src/components/MyComs/PullRefresh/index.vue +599 -0
  74. package/src/components/MyComs/Swiper/README.md +202 -0
  75. package/src/components/MyComs/Swiper/index.ts +2 -0
  76. package/src/components/MyComs/Swiper/index.vue +245 -0
  77. package/src/components/MyComs/Toast/README.md +604 -0
  78. package/src/components/MyComs/Toast/index.ts +2 -0
  79. package/src/components/MyComs/Toast/index.vue +372 -0
  80. package/src/components/MyComs/index.ts +33 -0
@@ -0,0 +1,684 @@
1
+ # Popup 弹窗组件
2
+
3
+ <div align="center">
4
+
5
+ ![Version](https://img.shields.io/badge/version-1.0.0-blue.svg)
6
+ ![License](https://img.shields.io/badge/license-MIT-green.svg)
7
+ ![Vue](https://img.shields.io/badge/Vue-3.x-brightgreen.svg)
8
+ ![Platform](https://img.shields.io/badge/platform-H5%20%7C%20MiniApp%20%7C%20App-orange.svg)
9
+
10
+ 一个功能强大、灵活易用的弹窗组件,支持多种位置、动画效果和自定义配置。
11
+
12
+ </div>
13
+
14
+ ---
15
+
16
+ ## 📋 目录
17
+
18
+ - [特性介绍](#-特性介绍)
19
+ - [快速开始](#-快速开始)
20
+ - [API文档](#-api文档)
21
+ - [使用示例](#-使用示例)
22
+ - [最佳实践](#-最佳实践)
23
+ - [常见问题](#-常见问题)
24
+
25
+ ---
26
+
27
+ ## ✨ 特性介绍
28
+
29
+ ### 🎯 核心功能
30
+ - ✅ **双向绑定**:支持 `v-model` 双向绑定控制显示/隐藏
31
+ - 🎨 **多种位置**:支持居中、顶部、底部、左侧、右侧位置
32
+ - 🎭 **丰富动画**:支持淡入淡出、缩放、滑动等动画效果
33
+ - 🖼️ **灵活遮罩**:可配置遮罩层透明度和点击关闭行为
34
+ - ⌨️ **键盘支持**:支持 ESC 键关闭弹窗
35
+ - 🔒 **滚动锁定**:弹窗打开时自动锁定背景滚动
36
+ - 📱 **响应式设计**:完美适配各种屏幕尺寸
37
+
38
+ ### 🎨 视觉效果
39
+ - 🎪 **模态/非模态**:支持带遮罩和无遮罩两种模式
40
+ - 🎯 **自定义样式**:支持自定义头部、内容和底部区域
41
+ - 🎬 **流畅动画**:所有动画效果均使用 CSS3 实现,性能优异
42
+ - 🎨 **现代设计**:采用现代扁平化设计风格
43
+
44
+ ### 🛠️ 技术特点
45
+ - 📦 **零依赖**:纯 CSS3 + Vue3 实现,无第三方依赖
46
+ - ⚡ **高性能**:使用 CSS3 硬件加速,流畅不卡顿
47
+ - 🔧 **易扩展**:支持插槽和事件回调,方便扩展
48
+ - 📚 **类型安全**:完整的 TypeScript 类型定义
49
+
50
+ ---
51
+
52
+ ## 🚀 快速开始
53
+
54
+ ### 安装使用
55
+
56
+ ```vue
57
+ <script setup lang="ts">
58
+ import { ref } from 'vue'
59
+ import Popup from '@/components/MyComs/Popup/index.vue'
60
+
61
+ const showPopup = ref(false)
62
+ </script>
63
+
64
+ <template>
65
+ <button @click="showPopup = true">打开弹窗</button>
66
+
67
+ <Popup v-model="showPopup" title="弹窗标题">
68
+ 弹窗内容
69
+ </Popup>
70
+ </template>
71
+ ```
72
+
73
+ ### 最小化配置
74
+
75
+ ```vue
76
+ <Popup v-model="visible">
77
+ 最简单的弹窗
78
+ </Popup>
79
+ ```
80
+
81
+ ---
82
+
83
+ ## 📚 API文档
84
+
85
+ ### Props 属性
86
+
87
+ | 参数名 | 类型 | 默认值 | 说明 |
88
+ |--------|------|--------|------|
89
+ | `modelValue` | `Boolean` | `false` | 控制弹窗显示/隐藏(支持v-model) |
90
+ | `title` | `String` | `''` | 弹窗标题 |
91
+ | `position` | `'center' \| 'top' \| 'bottom' \| 'left' \| 'right'` | `'center'` | 弹窗位置 |
92
+ | `animation` | `'fade' \| 'scale' \| 'slide'` | `'slide'` | 动画效果 |
93
+ | `mask` | `Boolean` | `true` | 是否显示遮罩层 |
94
+ | `maskOpacity` | `Number` | `0.5` | 遮罩层透明度(0-1) |
95
+ | `closeOnMaskClick` | `Boolean` | `true` | 点击遮罩是否关闭弹窗 |
96
+ | `showCloseButton` | `Boolean` | `true` | 是否显示关闭按钮 |
97
+ | `closeOnEsc` | `Boolean` | `true` | 是否支持Esc键关闭 |
98
+ | `showConfirmButton` | `Boolean` | `false` | 是否显示确认按钮 |
99
+ | `confirmText` | `String` | `'确定'` | 确认按钮文本 |
100
+ | `showCancelButton` | `Boolean` | `false` | 是否显示取消按钮 |
101
+ | `cancelText` | `String` | `'取消'` | 取消按钮文本 |
102
+ | `width` | `String \| Number` | `'50%'` | 弹窗宽度 |
103
+ | `height` | `String \| Number` | `'100%'` | 弹窗高度 |
104
+ | `maxWidth` | `String \| Number` | `'500px'` | 弹窗最大宽度 |
105
+ | `lockScroll` | `Boolean` | `true` | 是否禁止背景滚动 |
106
+
107
+ ### Events 事件
108
+
109
+ | 事件名 | 触发时机 | 参数 |
110
+ |--------|----------|------|
111
+ | `update:modelValue` | 弹窗显示状态改变 | `Boolean: visible` |
112
+ | `open` | 弹窗打开时 | - |
113
+ | `close` | 弹窗关闭时 | - |
114
+ | `maskClick` | 点击遮罩层时 | - |
115
+ | `confirm` | 点击确认按钮时 | - |
116
+ | `cancel` | 点击取消按钮时 | - |
117
+ | `closeButtonClick` | 点击关闭按钮时 | - |
118
+
119
+ ### Slots 插槽
120
+
121
+ | 插槽名 | 说明 |
122
+ |--------|------|
123
+ | `default` | 弹窗内容区域(默认插槽) |
124
+ | `header` | 弹窗头部区域(自定义头部时使用) |
125
+ | `footer` | 弹窗底部区域(自定义底部按钮时使用) |
126
+
127
+ ---
128
+
129
+ ## 📝 使用示例
130
+
131
+ ### 🎯 基本使用
132
+
133
+ ```vue
134
+ <template>
135
+ <button @click="showPopup = true">打开弹窗</button>
136
+
137
+ <Popup v-model="showPopup" title="弹窗标题">
138
+ 弹窗内容
139
+ </Popup>
140
+ </template>
141
+
142
+ <script setup lang="ts">
143
+ import { ref } from 'vue'
144
+ import Popup from '@/components/MyComs/Popup/index.vue'
145
+
146
+ const showPopup = ref(false)
147
+ </script>
148
+ ```
149
+
150
+ ### 🔘 带确认取消按钮
151
+
152
+ ```vue
153
+ <template>
154
+ <button @click="showConfirm = true">打开确认弹窗</button>
155
+
156
+ <Popup
157
+ v-model="showConfirm"
158
+ title="确认操作"
159
+ :show-confirm-button="true"
160
+ :show-cancel-button="true"
161
+ @confirm="handleConfirm"
162
+ @cancel="handleCancel"
163
+ >
164
+ 确定要执行此操作吗?
165
+ </Popup>
166
+ </template>
167
+
168
+ <script setup lang="ts">
169
+ import { ref } from 'vue'
170
+ import Popup from '@/components/MyComs/Popup/index.vue'
171
+
172
+ const showConfirm = ref(false)
173
+
174
+ const handleConfirm = () => {
175
+ console.log('确认操作')
176
+ showConfirm.value = false
177
+ }
178
+
179
+ const handleCancel = () => {
180
+ console.log('取消操作')
181
+ showConfirm.value = false
182
+ }
183
+ </script>
184
+ ```
185
+
186
+ ### 🎨 不同位置弹窗
187
+
188
+ ```vue
189
+ <template>
190
+ <div class="button-group">
191
+ <button @click="showTopPopup = true">顶部弹窗</button>
192
+ <button @click="showBottomPopup = true">底部弹窗</button>
193
+ <button @click="showLeftPopup = true">左侧弹窗</button>
194
+ <button @click="showRightPopup = true">右侧弹窗</button>
195
+ </div>
196
+
197
+ <!-- 顶部弹窗 -->
198
+ <Popup v-model="showTopPopup" position="top" title="顶部弹窗">
199
+ 这是一个从顶部弹出的消息提示弹窗
200
+ </Popup>
201
+
202
+ <!-- 底部弹窗 -->
203
+ <Popup v-model="showBottomPopup" position="bottom" title="底部弹窗">
204
+ 这是一个从底部弹出的菜单选择弹窗
205
+ </Popup>
206
+
207
+ <!-- 左侧弹窗 -->
208
+ <Popup v-model="showLeftPopup" position="left" width="60%" title="左侧菜单">
209
+ 这是一个侧边栏菜单弹窗
210
+ </Popup>
211
+
212
+ <!-- 右侧弹窗 -->
213
+ <Popup v-model="showRightPopup" position="right" width="60%" title="右侧面板">
214
+ 这是一个详情面板弹窗
215
+ </Popup>
216
+ </template>
217
+
218
+ <script setup lang="ts">
219
+ import { ref } from 'vue'
220
+ import Popup from '@/components/MyComs/Popup/index.vue'
221
+
222
+ const showTopPopup = ref(false)
223
+ const showBottomPopup = ref(false)
224
+ const showLeftPopup = ref(false)
225
+ const showRightPopup = ref(false)
226
+ </script>
227
+ ```
228
+
229
+ ### 🎭 动画效果演示
230
+
231
+ ```vue
232
+ <template>
233
+ <div class="demo-section">
234
+ <h3>动画效果</h3>
235
+ <div class="button-group">
236
+ <button @click="showFadePopup = true">淡入淡出</button>
237
+ <button @click="showScalePopup = true">缩放效果</button>
238
+ <button @click="showSlidePopup = true">滑动效果</button>
239
+ </div>
240
+ </div>
241
+
242
+ <!-- 淡入淡出动画 -->
243
+ <Popup
244
+ v-model="showFadePopup"
245
+ title="淡入淡出动画"
246
+ animation="fade"
247
+ :show-confirm-button="true"
248
+ @confirm="showFadePopup = false"
249
+ >
250
+ 这是一个使用淡入淡出动画效果的弹窗
251
+ </Popup>
252
+
253
+ <!-- 缩放动画 -->
254
+ <Popup
255
+ v-model="showScalePopup"
256
+ title="缩放动画"
257
+ animation="scale"
258
+ :show-confirm-button="true"
259
+ @confirm="showScalePopup = false"
260
+ >
261
+ 这是一个使用缩放动画效果的弹窗
262
+ </Popup>
263
+
264
+ <!-- 滑动动画 -->
265
+ <Popup
266
+ v-model="showSlidePopup"
267
+ title="滑动动画"
268
+ animation="slide"
269
+ :show-confirm-button="true"
270
+ @confirm="showSlidePopup = false"
271
+ >
272
+ 这是一个使用滑动动画效果的弹窗
273
+ </Popup>
274
+ </template>
275
+
276
+ <script setup lang="ts">
277
+ import { ref } from 'vue'
278
+ import Popup from '@/components/MyComs/Popup/index.vue'
279
+
280
+ const showFadePopup = ref(false)
281
+ const showScalePopup = ref(false)
282
+ const showSlidePopup = ref(false)
283
+ </script>
284
+ ```
285
+
286
+ ### 🛠️ 自定义头部和底部
287
+
288
+ ```vue
289
+ <template>
290
+ <button @click="showCustomPopup = true">自定义弹窗</button>
291
+
292
+ <Popup v-model="showCustomPopup">
293
+ <!-- 自定义头部 -->
294
+ <template #header>
295
+ <view class="custom-header">
296
+ <text class="custom-header-title">🎉 欢迎使用</text>
297
+ <text class="custom-header-subtitle">这是一个精美的自定义头部</text>
298
+ </view>
299
+ </template>
300
+
301
+ <view class="popup-content">
302
+ <p>这是弹窗的主要内容区域,您可以在这里放置任何内容。</p>
303
+ <p>支持文本、图片、表单等各种元素。</p>
304
+ </view>
305
+
306
+ <!-- 自定义底部 -->
307
+ <template #footer>
308
+ <view class="custom-footer">
309
+ <button class="custom-btn custom-btn-cancel" @click="showCustomPopup = false">
310
+ 返回
311
+ </button>
312
+ <button class="custom-btn custom-btn-save" @click="handleSave">
313
+ 保存
314
+ </button>
315
+ <button class="custom-btn custom-btn-submit" @click="handleSubmit">
316
+ 提交
317
+ </button>
318
+ </view>
319
+ </template>
320
+ </Popup>
321
+ </template>
322
+
323
+ <script setup lang="ts">
324
+ import { ref } from 'vue'
325
+ import Popup from '@/components/MyComs/Popup/index.vue'
326
+
327
+ const showCustomPopup = ref(false)
328
+
329
+ const handleSave = () => {
330
+ console.log('保存操作')
331
+ // 这里可以添加保存逻辑
332
+ }
333
+
334
+ const handleSubmit = () => {
335
+ console.log('提交操作')
336
+ showCustomPopup.value = false
337
+ }
338
+ </script>
339
+
340
+ <style scoped>
341
+ .custom-header {
342
+ text-align: center;
343
+ padding: 20px;
344
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
345
+ color: white;
346
+ border-radius: 16px 16px 0 0;
347
+ }
348
+
349
+ .custom-header-title {
350
+ font-size: 36rpx;
351
+ font-weight: 600;
352
+ margin-bottom: 8rpx;
353
+ }
354
+
355
+ .custom-header-subtitle {
356
+ font-size: 24rpx;
357
+ opacity: 0.8;
358
+ }
359
+
360
+ .popup-content {
361
+ padding: 40rpx;
362
+ line-height: 1.6;
363
+ }
364
+
365
+ .custom-footer {
366
+ display: flex;
367
+ justify-content: center;
368
+ gap: 20rpx;
369
+ padding: 20rpx;
370
+ }
371
+
372
+ .custom-btn {
373
+ padding: 16rpx 32rpx;
374
+ border: none;
375
+ border-radius: 8rpx;
376
+ font-size: 28rpx;
377
+ cursor: pointer;
378
+ transition: all 0.3s ease;
379
+ }
380
+
381
+ .custom-btn-cancel {
382
+ background-color: #f5f7fa;
383
+ color: #606266;
384
+ }
385
+
386
+ .custom-btn-save {
387
+ background-color: #409eff;
388
+ color: white;
389
+ }
390
+
391
+ .custom-btn-submit {
392
+ background-color: #67c23a;
393
+ color: white;
394
+ }
395
+
396
+ .custom-btn:hover {
397
+ transform: translateY(-2rpx);
398
+ box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.15);
399
+ }
400
+ </style>
401
+ ```
402
+
403
+ ### 🎨 高级配置示例
404
+
405
+ ```vue
406
+ <template>
407
+ <button @click="showAdvancedPopup = true">高级配置弹窗</button>
408
+
409
+ <Popup
410
+ v-model="showAdvancedPopup"
411
+ title="高级配置"
412
+ position="center"
413
+ animation="scale"
414
+ :mask="true"
415
+ :mask-opacity="0.7"
416
+ :close-on-mask-click="true"
417
+ :show-close-button="true"
418
+ :show-confirm-button="true"
419
+ :show-cancel-button="true"
420
+ confirm-text="确认"
421
+ cancel-text="取消"
422
+ width="80%"
423
+ :max-width="'400px'"
424
+ :lock-scroll="true"
425
+ :close-on-esc="true"
426
+ @confirm="handleAdvancedConfirm"
427
+ @cancel="handleAdvancedCancel"
428
+ @mask-click="handleMaskClick"
429
+ @open="handlePopupOpen"
430
+ @close="handlePopupClose"
431
+ >
432
+ <view class="advanced-content">
433
+ <text>这是一个高级配置的弹窗示例</text>
434
+ <text>包含了所有可配置的选项</text>
435
+ </view>
436
+ </Popup>
437
+ </template>
438
+
439
+ <script setup lang="ts">
440
+ import { ref } from 'vue'
441
+ import Popup from '@/components/MyComs/Popup/index.vue'
442
+
443
+ const showAdvancedPopup = ref(false)
444
+
445
+ const handleAdvancedConfirm = () => {
446
+ console.log('高级弹窗确认')
447
+ showAdvancedPopup.value = false
448
+ }
449
+
450
+ const handleAdvancedCancel = () => {
451
+ console.log('高级弹窗取消')
452
+ showAdvancedPopup.value = false
453
+ }
454
+
455
+ const handleMaskClick = () => {
456
+ console.log('点击了遮罩层')
457
+ }
458
+
459
+ const handlePopupOpen = () => {
460
+ console.log('弹窗打开了')
461
+ }
462
+
463
+ const handlePopupClose = () => {
464
+ console.log('弹窗关闭了')
465
+ }
466
+ </script>
467
+
468
+ <style scoped>
469
+ .advanced-content {
470
+ padding: 40rpx;
471
+ text-align: center;
472
+ }
473
+
474
+ .advanced-content text {
475
+ display: block;
476
+ margin-bottom: 20rpx;
477
+ font-size: 28rpx;
478
+ color: #606266;
479
+ }
480
+ </style>
481
+ ```
482
+
483
+ ---
484
+
485
+ ## 💡 最佳实践
486
+
487
+ ### 🎯 场景选择指南
488
+
489
+ | 使用场景 | 推荐配置 | 说明 |
490
+ |----------|----------|------|
491
+ | **信息提示** | `position: center`, `animation: fade` | 简洁明了,不干扰用户操作 |
492
+ | **确认操作** | `showConfirmButton: true`, `showCancelButton: true` | 提供明确的确认和取消选项 |
493
+ | **菜单选择** | `position: bottom`, `animation: slide` | 适合移动端的底部操作面板 |
494
+ | **侧边栏** | `position: left/right`, `width: 60%` | 类似抽屉的侧边导航 |
495
+ | **表单填写** | `position: center`, `lockScroll: true` | 避免背景滚动干扰 |
496
+ | **图片预览** | `maskOpacity: 0.9`, `showCloseButton: true` | 突出显示内容 |
497
+
498
+ ### 🚀 性能优化建议
499
+
500
+ 1. **合理使用动画**
501
+ ```vue
502
+ <!-- 推荐:使用硬件加速的动画 -->
503
+ <Popup animation="fade" />
504
+
505
+ <!-- 避免:在低端设备上使用复杂动画 -->
506
+ <Popup animation="scale" />
507
+ ```
508
+
509
+ 2. **控制弹窗数量**
510
+ ```vue
511
+ <!-- 推荐:使用v-if条件渲染 -->
512
+ <Popup v-if="showPopup" v-model="showPopup" />
513
+
514
+ <!-- 避免:同时显示多个弹窗 -->
515
+ ```
516
+
517
+ 3. **优化内容渲染**
518
+ ```vue
519
+ <!-- 推荐:懒加载内容 -->
520
+ <Popup v-model="showPopup">
521
+ <LazyContent v-if="showPopup" />
522
+ </Popup>
523
+ ```
524
+
525
+ ### 🎨 样式定制指南
526
+
527
+ 1. **全局样式覆盖**
528
+ ```css
529
+ /* 在全局CSS中定义自定义样式 */
530
+ .custom-popup .popup-container {
531
+ border-radius: 20rpx;
532
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
533
+ }
534
+ ```
535
+
536
+ 2. **响应式适配**
537
+ ```vue
538
+ <Popup
539
+ :width="isMobile ? '90%' : '50%'"
540
+ :max-width="isMobile ? '350px' : '500px'"
541
+ />
542
+ ```
543
+
544
+ ### 🔧 常见陷阱避免
545
+
546
+ 1. **v-model 绑定问题**
547
+ ```vue
548
+ <!-- 错误:直接使用 props 值 -->
549
+ <Popup :modelValue="propsValue" />
550
+
551
+ <!-- 正确:使用 ref 响应式变量 -->
552
+ <Popup v-model="localValue" />
553
+ ```
554
+
555
+ 2. **事件处理优化**
556
+ ```vue
557
+ <!-- 推荐:使用箭头函数或显式绑定 -->
558
+ @confirm="() => handleConfirm(id)"
559
+ @cancel="handleCancel.bind(this, id)"
560
+ ```
561
+
562
+ 3. **内存泄漏预防**
563
+ ```vue
564
+ <script setup lang="ts">
565
+ import { onUnmounted } from 'vue'
566
+
567
+ // 组件卸载时清理资源
568
+ onUnmounted(() => {
569
+ // 清理定时器、事件监听等
570
+ })
571
+ </script>
572
+ ```
573
+
574
+ ---
575
+
576
+ ## ❓ 常见问题
577
+
578
+ ### 🔍 FAQ
579
+
580
+ **Q: 如何禁用 ESC 键关闭弹窗?**
581
+ ```vue
582
+ <Popup :close-on-esc="false" v-model="show" />
583
+ ```
584
+
585
+ **Q: 如何在弹窗外部点击时不关闭?**
586
+ ```vue
587
+ <Popup :close-on-mask-click="false" v-model="show" />
588
+ ```
589
+
590
+ **Q: 如何自定义弹窗的动画时长?**
591
+ ```vue
592
+ <!-- 目前固定为0.3s,可通过CSS覆盖 -->
593
+ <Popup v-model="show" class="custom-duration" />
594
+
595
+ <style>
596
+ .custom-duration .popup-container {
597
+ transition: all 0.5s ease;
598
+ }
599
+ </style>
600
+ ```
601
+
602
+ **Q: 在uni-app小程序中如何使用?**
603
+ ```vue
604
+ <!-- 完全兼容,无需特殊配置 -->
605
+ <Popup v-model="showPopup" title="小程序弹窗">
606
+ 小程序内容
607
+ </Popup>
608
+ ```
609
+
610
+ **Q: 如何实现无遮罩的弹窗?**
611
+ ```vue
612
+ <Popup :mask="false" v-model="showPopup">
613
+ 无遮罩弹窗
614
+ </Popup>
615
+ ```
616
+
617
+ **Q: 弹窗内容过长如何处理?**
618
+ ```vue
619
+ <Popup v-model="showPopup">
620
+ <scroll-view scroll-y style="max-height: 400rpx;">
621
+ 长内容区域
622
+ </scroll-view>
623
+ </Popup>
624
+ ```
625
+
626
+ **Q: 如何监听弹窗的打开/关闭事件?**
627
+ ```vue
628
+ <Popup
629
+ v-model="showPopup"
630
+ @open="onOpen"
631
+ @close="onClose"
632
+ />
633
+
634
+ <script setup>
635
+ const onOpen = () => console.log('弹窗打开了')
636
+ const onClose = () => console.log('弹窗关闭了')
637
+ </script>
638
+ ```
639
+
640
+ ### 🐛 问题排查
641
+
642
+ 1. **弹窗不显示**
643
+ - 检查 `v-model` 绑定的变量是否为响应式
644
+ - 确认 `showPopup` 初始值为 `true`
645
+
646
+ 2. **动画效果异常**
647
+ - 检查是否与其他CSS动画冲突
648
+ - 确认浏览器支持CSS3动画
649
+
650
+ 3. **在某些设备上显示异常**
651
+ - 检查viewport设置
652
+ - 确认uni-app版本兼容性
653
+
654
+ 4. **事件不触发**
655
+ - 检查事件处理函数是否正确定义
656
+ - 确认函数作用域正确
657
+
658
+ ---
659
+
660
+ ## 📄 更新日志
661
+
662
+ ### v1.0.0 (2024-01-01)
663
+ - ✨ 初始版本发布
664
+ - 🎯 支持五种位置模式
665
+ - 🎭 支持三种动画效果
666
+ - 🛠️ 完整的TypeScript类型定义
667
+ - 📱 响应式设计适配
668
+ - 🔧 丰富的配置选项
669
+
670
+ ---
671
+
672
+ ## 📄 许可证
673
+
674
+ MIT License
675
+
676
+ ---
677
+
678
+ <div align="center">
679
+
680
+ **如果这个组件对您有帮助,请给个 ⭐ Star!**
681
+
682
+ Made with ❤️ by Your Team
683
+
684
+ </div>
@@ -0,0 +1,2 @@
1
+ import Component from './index.vue';
2
+ export default Component;