@fredwsw/frontend-rules 1.0.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.
Files changed (81) hide show
  1. package/README.md +302 -0
  2. package/bin/cli.js +155 -0
  3. package/package.json +22 -0
  4. package/template/docs/uv-ui-docs/action-sheet-cn.md +180 -0
  5. package/template/docs/uv-ui-docs/album-cn.md +104 -0
  6. package/template/docs/uv-ui-docs/alert-cn.md +71 -0
  7. package/template/docs/uv-ui-docs/avatar-cn.md +149 -0
  8. package/template/docs/uv-ui-docs/back-top-cn.md +121 -0
  9. package/template/docs/uv-ui-docs/badge-cn.md +100 -0
  10. package/template/docs/uv-ui-docs/button-cn.md +181 -0
  11. package/template/docs/uv-ui-docs/calendar-cn.md +179 -0
  12. package/template/docs/uv-ui-docs/calendars-cn.md +264 -0
  13. package/template/docs/uv-ui-docs/cell-cn.md +163 -0
  14. package/template/docs/uv-ui-docs/checkbox-cn.md +164 -0
  15. package/template/docs/uv-ui-docs/code-cn.md +122 -0
  16. package/template/docs/uv-ui-docs/code-input-cn.md +127 -0
  17. package/template/docs/uv-ui-docs/collapse-cn.md +206 -0
  18. package/template/docs/uv-ui-docs/color-cn.md +122 -0
  19. package/template/docs/uv-ui-docs/count-down-cn.md +169 -0
  20. package/template/docs/uv-ui-docs/count-to-cn.md +125 -0
  21. package/template/docs/uv-ui-docs/datetime-picker-cn.md +167 -0
  22. package/template/docs/uv-ui-docs/divider-cn.md +90 -0
  23. package/template/docs/uv-ui-docs/drop-down-cn.md +287 -0
  24. package/template/docs/uv-ui-docs/empty-cn.md +76 -0
  25. package/template/docs/uv-ui-docs/form-cn.md +220 -0
  26. package/template/docs/uv-ui-docs/gap-cn.md +63 -0
  27. package/template/docs/uv-ui-docs/grid-cn.md +187 -0
  28. package/template/docs/uv-ui-docs/icon-cn.md +255 -0
  29. package/template/docs/uv-ui-docs/image-cn.md +170 -0
  30. package/template/docs/uv-ui-docs/index-list-cn.md +132 -0
  31. package/template/docs/uv-ui-docs/input-cn.md +157 -0
  32. package/template/docs/uv-ui-docs/keyboard-cn.md +156 -0
  33. package/template/docs/uv-ui-docs/layout-cn.md +215 -0
  34. package/template/docs/uv-ui-docs/line-cn.md +77 -0
  35. package/template/docs/uv-ui-docs/line-progress-cn.md +132 -0
  36. package/template/docs/uv-ui-docs/link-cn.md +97 -0
  37. package/template/docs/uv-ui-docs/list-cn.md +185 -0
  38. package/template/docs/uv-ui-docs/load-more-cn.md +144 -0
  39. package/template/docs/uv-ui-docs/loading-icon-cn.md +125 -0
  40. package/template/docs/uv-ui-docs/loading-page-cn.md +85 -0
  41. package/template/docs/uv-ui-docs/modal-cn.md +212 -0
  42. package/template/docs/uv-ui-docs/navbar-cn.md +171 -0
  43. package/template/docs/uv-ui-docs/no-network-cn.md +112 -0
  44. package/template/docs/uv-ui-docs/notice-bar-cn.md +119 -0
  45. package/template/docs/uv-ui-docs/notify-cn.md +185 -0
  46. package/template/docs/uv-ui-docs/number-box-cn.md +131 -0
  47. package/template/docs/uv-ui-docs/overlay-cn.md +122 -0
  48. package/template/docs/uv-ui-docs/parse-cn.md +177 -0
  49. package/template/docs/uv-ui-docs/pick-color-cn.md +147 -0
  50. package/template/docs/uv-ui-docs/picker-cn.md +159 -0
  51. package/template/docs/uv-ui-docs/popup-cn.md +184 -0
  52. package/template/docs/uv-ui-docs/qrcode-cn.md +150 -0
  53. package/template/docs/uv-ui-docs/radio-cn.md +166 -0
  54. package/template/docs/uv-ui-docs/rate-cn.md +91 -0
  55. package/template/docs/uv-ui-docs/read-more-cn.md +191 -0
  56. package/template/docs/uv-ui-docs/scroll-list-cn.md +188 -0
  57. package/template/docs/uv-ui-docs/search-cn.md +107 -0
  58. package/template/docs/uv-ui-docs/skeleton-cn.md +101 -0
  59. package/template/docs/uv-ui-docs/skeletons-cn.md +312 -0
  60. package/template/docs/uv-ui-docs/slider-cn.md +98 -0
  61. package/template/docs/uv-ui-docs/steps-cn.md +158 -0
  62. package/template/docs/uv-ui-docs/sticky-cn.md +82 -0
  63. package/template/docs/uv-ui-docs/subsection-cn.md +161 -0
  64. package/template/docs/uv-ui-docs/swipe-action-cn.md +207 -0
  65. package/template/docs/uv-ui-docs/swiper-cn.md +247 -0
  66. package/template/docs/uv-ui-docs/switch-cn.md +136 -0
  67. package/template/docs/uv-ui-docs/tabbar-cn.md +224 -0
  68. package/template/docs/uv-ui-docs/tabs-cn.md +260 -0
  69. package/template/docs/uv-ui-docs/tags-cn.md +191 -0
  70. package/template/docs/uv-ui-docs/text-cn.md +178 -0
  71. package/template/docs/uv-ui-docs/textarea-cn.md +132 -0
  72. package/template/docs/uv-ui-docs/toast-cn.md +110 -0
  73. package/template/docs/uv-ui-docs/tooltip-cn.md +91 -0
  74. package/template/docs/uv-ui-docs/transition-cn.md +202 -0
  75. package/template/docs/uv-ui-docs/upload-cn.md +156 -0
  76. package/template/docs/uv-ui-docs/vtabs-cn.md +190 -0
  77. package/template/docs/uv-ui-docs/waterfall-cn.md +276 -0
  78. package/template/rules/common.mdc +90 -0
  79. package/template/rules/uv-ui-docs.mdc +111 -0
  80. package/template/skills/code-simplifier/SKILL.md +109 -0
  81. package/template/skills/frontend-design/SKILL.md +44 -0
@@ -0,0 +1,132 @@
1
+ ---
2
+ group: 表单
3
+ category: Components
4
+ title: Textarea
5
+ subtitle: 文本域
6
+ description: 满足表单信息补充、编辑等场景,内置字数统计、自动增高等能力。
7
+ demo:
8
+ cols: 2
9
+ ---
10
+
11
+ ## 何时使用 {#when-to-use}
12
+
13
+ `uv-textarea` 用于多行文本输入,如表单补充、编辑等,支持字数统计、自动增高、格式化等。
14
+
15
+ > 完整示例下载地址:[uv-ui 插件市场](https://ext.dcloud.net.cn/plugin?name=uv-ui)
16
+
17
+ ## 平台兼容性 {#platform}
18
+
19
+ | App(vue) | App(nvue) | H5 | 小程序 | VUE2 | VUE3 |
20
+ | --- | --- | --- | --- | --- | --- |
21
+ | √ | √ | √ | √ | √ | √ |
22
+
23
+ **组件名:** `uv-textarea`
24
+
25
+ ## 代码演示 {#examples}
26
+
27
+ ### 基本使用 {#basic}
28
+
29
+ ```vue
30
+ <template>
31
+ <uv-textarea v-model="value" placeholder="请输入内容"></uv-textarea>
32
+ </template>
33
+ <script>
34
+ export default {
35
+ data() {
36
+ return { value: '' }
37
+ }
38
+ }
39
+ </script>
40
+ ```
41
+
42
+ ### 字数统计 {#count}
43
+
44
+ ```vue
45
+ <uv-textarea v-model="value" count placeholder="请输入内容"></uv-textarea>
46
+ ```
47
+
48
+ ### 自动增高 {#auto-height}
49
+
50
+ ```vue
51
+ <uv-textarea
52
+ v-model="value"
53
+ :maxlength="-1"
54
+ autoHeight
55
+ placeholder="请输入内容"
56
+ ></uv-textarea>
57
+ ```
58
+
59
+ ### 禁用状态 {#disabled}
60
+
61
+ ```vue
62
+ <uv-textarea v-model="value" disabled placeholder="请输入内容"></uv-textarea>
63
+ ```
64
+
65
+ ### 下划线模式 {#border}
66
+
67
+ ```vue
68
+ <uv-textarea v-model="value" border="bottom" placeholder="请输入内容"></uv-textarea>
69
+ ```
70
+
71
+ ### 格式化 {#formatter}
72
+
73
+ 通过 `formatter` 自定义格式化。某些平台不支持 props 传函数,可在 `onReady` 中调用 `this.$refs.textarea.setFormatter(this.formatter)`。
74
+
75
+ ```vue
76
+ <template>
77
+ <uv-textarea v-model="value" :formatter="formatter" placeholder="请输入内容"></uv-textarea>
78
+ </template>
79
+ <script>
80
+ export default {
81
+ data() {
82
+ return { value: '' }
83
+ },
84
+ methods: {
85
+ formatter(value) {
86
+ return value.replace(/[^0-9]/ig, '')
87
+ }
88
+ }
89
+ }
90
+ </script>
91
+ ```
92
+
93
+ ## API {#api}
94
+
95
+ ### Textarea Props {#props}
96
+
97
+ 部分参数参考 [uniapp textarea 文档](https://uniapp.dcloud.net.cn/component/textarea.html)。
98
+
99
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 |
100
+ | --- | --- | --- | --- | --- |
101
+ | value / v-model | 内容 | String | - | - |
102
+ | placeholder | 占位符 | String | - | - |
103
+ | height | 高度 | String \| Number | 70 | - |
104
+ | confirmType | 键盘右下角按钮文字 | String | done | - |
105
+ | confirmHold | 点击完成是否保持键盘 | Boolean | false | true \| false |
106
+ | disabled | 是否禁用 | Boolean | false | true \| false |
107
+ | count | 是否显示字数统计 | Boolean | false | true \| false |
108
+ | focus | 是否自动聚焦 | Boolean | false | true \| false |
109
+ | autoHeight | 是否自动增高 | Boolean | false | true \| false |
110
+ | maxlength | 最大长度,-1 不限制 | String \| Number | 140 | - |
111
+ | border | 边框类型 | String | surround | surround \| bottom \| none |
112
+ | formatter | 格式化函数(微信可用 setFormatter) | Function | null | - |
113
+ | textStyle | 文本样式 | Object | - | - |
114
+ | countStyle | 字数统计样式 | Object | - | - |
115
+ | customStyle | 自定义外部样式 | Object | - | - |
116
+
117
+ ### Textarea Methods {#methods}
118
+
119
+ | 方法名 | 说明 |
120
+ | --- | --- |
121
+ | setFormatter | 兼容微信小程序,设置 formatter |
122
+
123
+ ### Textarea Events {#events}
124
+
125
+ | 事件名 | 说明 | 回调参数 |
126
+ | --- | --- | --- |
127
+ | @focus | 聚焦 | event.detail = { value, height } |
128
+ | @blur | 失去焦点 | event.detail = { value, cursor } |
129
+ | @linechange | 行数变化 | event.detail = { height, heightRpx, lineCount } |
130
+ | @input | 输入 | e.detail.value |
131
+ | @confirm | 点击完成 | e |
132
+ | @keyboardheightchange | 键盘高度变化 | e |
@@ -0,0 +1,110 @@
1
+ ---
2
+ group: 基础
3
+ category: Components
4
+ title: Toast
5
+ subtitle: 消息提示
6
+ description: 用于消息通知、加载提示、操作结果提示等醒目反馈,支持 ref API 调用与丰富参数配置。
7
+ demo:
8
+ cols: 2
9
+ ---
10
+
11
+ ## 何时使用 {#when-to-use}
12
+
13
+ `uv-toast` 主要用于消息通知、加载提示、操作结果提示等醒目提示效果,提供丰富 API,使用方式类似 `uni.showToast`。
14
+
15
+ 注意:所有有关 `ref` 的调用不要在页面 `onLoad` 生命周期执行(组件未创建完会报错),应在 `onReady` 生命周期调用。
16
+
17
+ > 完整示例下载地址:[uv-ui 插件市场](https://ext.dcloud.net.cn/plugin?name=uv-ui)
18
+
19
+ ## 平台兼容性 {#platform}
20
+
21
+ | App(vue) | App(nvue) | H5 | 小程序 | VUE2 | VUE3 |
22
+ | --- | --- | --- | --- | --- | --- |
23
+ | √ | √ | √ | √ | √ | √ |
24
+
25
+ **组件名:** `uv-toast`
26
+
27
+ ## 代码演示 {#examples}
28
+
29
+ ### 基本使用 {#basic}
30
+
31
+ 通过 `ref` 调用组件内部 `show` 方法显示,并传入参数(见下方 Toast Params)。
32
+
33
+ ```vue
34
+ <template>
35
+ <view>
36
+ <uv-toast ref="toast"></uv-toast>
37
+ <view class="list">
38
+ <view class="item" v-for="(item, index) in list" :key="index" @click="showToast(item)">{{ item.title }}</view>
39
+ </view>
40
+ </view>
41
+ </template>
42
+
43
+ <script>
44
+ export default {
45
+ data() {
46
+ return {
47
+ list: [
48
+ { type: 'default', title: '默认主题', message: '锦瑟无端五十弦' },
49
+ { type: 'error', icon: false, title: '失败主题', message: '一弦一柱思华年' },
50
+ { type: 'success', title: '成功主题(带图标)', message: '庄生晓梦迷蝴蝶' },
51
+ { type: 'loading', title: '正在加载', message: '正在加载' },
52
+ { type: 'default', title: '结束后跳转标签页', message: '此情可待成追忆', url: '/pages/componentsD/tag/tag' }
53
+ ]
54
+ }
55
+ },
56
+ methods: {
57
+ showToast(params) {
58
+ this.$refs.toast.show({
59
+ ...params,
60
+ complete() {
61
+ params.url &&
62
+ uni.navigateTo({
63
+ url: params.url
64
+ })
65
+ }
66
+ })
67
+ }
68
+ }
69
+ }
70
+ </script>
71
+
72
+ <style lang="scss" scoped>
73
+ .item {
74
+ margin: 10rpx 0;
75
+ padding: 10rpx;
76
+ text-align: center;
77
+ background: #f1f1f1;
78
+ font-size: 28rpx;
79
+ color: #666;
80
+ }
81
+ </style>
82
+ ```
83
+
84
+ ## API {#api}
85
+
86
+ ### Toast Params {#params}
87
+
88
+ 通过 `ref` 调用 `<uv-toast />` 的 `show` 方法时传入:
89
+
90
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 |
91
+ | --- | --- | --- | --- | --- |
92
+ | loading | 是否加载中 | Boolean | false | true \| false |
93
+ | z-index | toast 展示层级 | String \| Number | 10090 | - |
94
+ | overlay | 是否显示透明遮罩防止穿透 | Boolean | true | true \| false |
95
+ | message | 显示文本 | String \| Number | - | - |
96
+ | icon | 图标或绝对路径图片 | String | - | - |
97
+ | position | 出现位置 | String | center | top \| bottom |
98
+ | type | 主题类型 | String | - | - |
99
+ | params | 跳转参数 | Object | - | - |
100
+ | duration | 展示时长(ms) | String \| Number | 2000 | - |
101
+ | complete | 结束回调函数 | Function | null | - |
102
+
103
+ ### Toast Methods {#methods}
104
+
105
+ 方法通过 `ref` 调用。
106
+
107
+ | 方法名 | 说明 | 参数 |
108
+ | --- | --- | --- |
109
+ | show | 显示 toast(如需进入页面即显示,请在 onReady 调用) | Toast Params |
110
+ | hide | 隐藏 toast | - |
@@ -0,0 +1,91 @@
1
+ ---
2
+ group: 基础
3
+ category: Components
4
+ title: Tooltip
5
+ subtitle: 长按提示
6
+ description: 类似微信长按气泡的提示组件,支持方向、扩展按钮、遮罩与复制能力。
7
+ demo:
8
+ cols: 2
9
+ ---
10
+
11
+ ## 何时使用 {#when-to-use}
12
+
13
+ `uv-tooltip` 主要用于长按操作提示,类似微信的长按气泡。
14
+
15
+ 说明:由于安卓 nvue 下 `overflow` 不支持 `visible`,组件暂不支持安卓 nvue 环境。
16
+
17
+ > 完整示例下载地址:[uv-ui 插件市场](https://ext.dcloud.net.cn/plugin?name=uv-ui)
18
+
19
+ ## 平台兼容性 {#platform}
20
+
21
+ | App(vue) | App(nvue) | H5 | 小程序 | VUE2 | VUE3 |
22
+ | --- | --- | --- | --- | --- | --- |
23
+ | √ | × | √ | √ | √ | √ |
24
+
25
+ **组件名:** `uv-tooltip`
26
+
27
+ ## 代码演示 {#examples}
28
+
29
+ ### 基本使用 {#basic}
30
+
31
+ 通过 `text` 控制文本。
32
+
33
+ ```vue
34
+ <template>
35
+ <uv-tooltip text="复制" overlay></uv-tooltip>
36
+ </template>
37
+ ```
38
+
39
+ ### 下方显示 {#direction}
40
+
41
+ 通过 `direction` 控制方向。
42
+
43
+ ```vue
44
+ <template>
45
+ <uv-tooltip text="下方显示" direction="bottom"></uv-tooltip>
46
+ </template>
47
+ ```
48
+
49
+ ### 扩展按钮 {#buttons}
50
+
51
+ 通过 `buttons` 扩展按钮组。
52
+
53
+ ```vue
54
+ <template>
55
+ <uv-tooltip text="扩展显示" :buttons="['扩展']"></uv-tooltip>
56
+ </template>
57
+ ```
58
+
59
+ ### 高亮选中文本背景色 {#bgcolor}
60
+
61
+ 通过 `bgColor` 设置背景色。
62
+
63
+ ```vue
64
+ <template>
65
+ <uv-tooltip text="高亮选中文本背景色" :buttons="['扩展']" bgColor="#e3e4e6"></uv-tooltip>
66
+ </template>
67
+ ```
68
+
69
+ ## API {#api}
70
+
71
+ ### Tooltip Props {#props}
72
+
73
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 |
74
+ | --- | --- | --- | --- | --- |
75
+ | text | 提示文字 | String \| Number | - | - |
76
+ | copyText | 点击复制按钮时复制的文本(为空则使用 text) | String \| Number | - | - |
77
+ | size | 文本大小 | String \| Number | 14 | - |
78
+ | color | 字体颜色 | String | #606266 | - |
79
+ | bgColor | 提示框背景色 | String | transparent | - |
80
+ | direction | 弹出方向 | String | top | top \| bottom |
81
+ | zIndex | 弹出层级(nvue 无效) | String \| Number | 10071 | - |
82
+ | showCopy | 是否显示复制按钮 | Boolean | true | true \| false |
83
+ | buttons | 扩展按钮组 | Array | - | - |
84
+ | overlay | 是否显示透明遮罩防止穿透 | Boolean | true | true \| false |
85
+ | showToast | 是否显示复制成功/失败 toast | Boolean | true | true \| false |
86
+
87
+ ### Tooltip Events {#events}
88
+
89
+ | 事件名 | 说明 | 回调参数 |
90
+ | --- | --- | --- |
91
+ | @click | 点击触发 | index:被点击按钮索引 |
@@ -0,0 +1,202 @@
1
+ ---
2
+ group: 基础
3
+ category: Components
4
+ title: Transition
5
+ subtitle: 动画
6
+ description: 用于元素的动画过渡效果,丰富的内置动画,支持自定义动画。
7
+ demo:
8
+ cols: 2
9
+ ---
10
+
11
+ ## 何时使用 {#when-to-use}
12
+
13
+ `uv-transition` 用于元素的动画过渡效果,内置多种过渡动画,并支持通过 `step()` 和 `run()` 自定义动画。
14
+
15
+ > 完整示例下载地址:[uv-ui 插件市场](https://ext.dcloud.net.cn/plugin?name=uv-ui)
16
+
17
+ ## 平台兼容性 {#platform}
18
+
19
+ | App(vue) | App(nvue) | H5 | 小程序 | VUE2 | VUE3 |
20
+ | --- | --- | --- | --- | --- | --- |
21
+ | √ | √ | √ | √ | √ | √ |
22
+
23
+ **组件名:** `uv-transition`
24
+
25
+ ## 代码演示 {#examples}
26
+
27
+ ### 基本使用 {#basic}
28
+
29
+ 通过 `show` 属性设置动画的打开和关闭。
30
+
31
+ ```vue
32
+ <template>
33
+ <button type="default" @click="open">fade</button>
34
+ <uv-transition
35
+ :show="show"
36
+ :custom-style="{'width':'100px','height':'100px','backgroundColor':'#3c9cff'}"
37
+ @change="change"
38
+ ></uv-transition>
39
+ </template>
40
+ <script>
41
+ export default {
42
+ data() {
43
+ return { show: false }
44
+ },
45
+ methods: {
46
+ open() {
47
+ this.show = !this.show
48
+ },
49
+ change(e) {
50
+ console.log('动画触发:', e)
51
+ }
52
+ }
53
+ }
54
+ </script>
55
+ ```
56
+
57
+ ### 动画模式 {#mode}
58
+
59
+ 通过 `mode` 属性设置动画模式,默认 `fade`。如 `mode="zoom-in"` 可实现由小到大过渡,更多模式见下方 Mode Options。
60
+
61
+ ```vue
62
+ <template>
63
+ <button type="default" @click="open">zoom-in</button>
64
+ <uv-transition
65
+ :show="show"
66
+ mode="zoom-in"
67
+ :custom-style="{'width':'100px','height':'100px','backgroundColor':'#3c9cff'}"
68
+ @change="change"
69
+ ></uv-transition>
70
+ </template>
71
+ <script>
72
+ export default {
73
+ data() {
74
+ return { show: false }
75
+ },
76
+ methods: {
77
+ open() {
78
+ this.show = !this.show
79
+ },
80
+ change(e) {
81
+ console.log('动画触发:', e)
82
+ }
83
+ }
84
+ }
85
+ </script>
86
+ ```
87
+
88
+ ### 自定义动画 {#custom}
89
+
90
+ 当内置动画不满足需求时,可使用 `step()` 和 `run()` 自定义动画。`init()` 可覆盖默认配置。
91
+
92
+ ```vue
93
+ <template>
94
+ <view>
95
+ <button type="primary" @click="run">执行动画</button>
96
+ <uv-transition
97
+ ref="ani"
98
+ :custom-style="{'width':'100px','height':'100px','backgroundColor':'#3c9cff'}"
99
+ :show="show"
100
+ />
101
+ </view>
102
+ </template>
103
+ <script>
104
+ export default {
105
+ data() {
106
+ return { show: true }
107
+ },
108
+ onReady() {
109
+ this.$refs.ani.init({
110
+ duration: 1000,
111
+ timingFunction: 'linear',
112
+ transformOrigin: '50% 50%',
113
+ delay: 500
114
+ })
115
+ },
116
+ methods: {
117
+ run() {
118
+ this.$refs.ani.step({
119
+ translateX: '100px',
120
+ rotate: '360'
121
+ })
122
+ this.$refs.ani.step(
123
+ { translateX: '0px', rotate: '0' },
124
+ { timingFunction: 'ease-in', duration: 200 }
125
+ )
126
+ this.$refs.ani.run(() => {
127
+ console.log('动画支持完毕')
128
+ })
129
+ }
130
+ }
131
+ }
132
+ </script>
133
+ ```
134
+
135
+ ## API {#api}
136
+
137
+ ### Transition Props {#props}
138
+
139
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 |
140
+ | --- | --- | --- | --- | --- |
141
+ | show | 控制组件显示或关闭 | Boolean | false | true \| false |
142
+ | mode | 内置过渡动画类型 | String | fade | 见 Mode Options |
143
+ | duration | 动画执行时间,单位 ms | String \| Number | 300 | - |
144
+ | timingFunction | 动画过渡函数 | String | ease-out | - |
145
+ | customClass | 自定义类名 | String | - | - |
146
+ | cellChild | 是否属于 cell 节点下(nvue 下避免回收不显示) | Boolean | false | true \| false |
147
+ | customStyle | 自定义样式 | Object | - | - |
148
+
149
+ ### Mode Options {#mode-options}
150
+
151
+ 格式:`'fade'` 或 `['fade','slide-top']`。注意:组合时同种相反类型如 slide-top、slide-bottom 同时使用,仅最后一个生效。
152
+
153
+ | 属性值 | 说明 |
154
+ | --- | --- |
155
+ | fade | 渐隐渐出过渡 |
156
+ | slide-top | 由上至下过渡 |
157
+ | slide-bottom | 由下至上过渡 |
158
+ | slide-left | 由左至右过渡 |
159
+ | slide-right | 由右至左过渡 |
160
+ | zoom-in | 由小到大过渡 |
161
+ | zoom-out | 由大到小过渡 |
162
+
163
+ ### Transition Events {#events}
164
+
165
+ | 事件名 | 说明 | 回调参数 |
166
+ | --- | --- | --- |
167
+ | @click | 点击组件触发 | - |
168
+ | @change | 过渡动画结束时触发 | e = {detail: true \| false} |
169
+
170
+ ### Transition Methods {#methods}
171
+
172
+ 通过 ref 调用。
173
+
174
+ | 方法名 | 说明 | 参数 |
175
+ | --- | --- | --- |
176
+ | init() | 手动初始化配置 | init(OBJECT:config) |
177
+ | step() | 动画队列 | step(OBJECT:type, OBJECT:config) |
178
+ | run() | 执行动画 | run(FUNCTION:callback) |
179
+
180
+ ### 动画配置 {#config}
181
+
182
+ `init()` 与 `step()` 第二个参数相同,`step()` 的第二个参数会覆盖 `init()` 的配置。
183
+
184
+ | 属性名 | 类型 | 默认值 | 说明 |
185
+ | --- | --- | --- | --- |
186
+ | duration | Number | 400 | 动画持续时间,单位 ms |
187
+ | timingFunction | String | linear | 见下方说明 |
188
+ | delay | Number | 0 | 动画延迟时间,单位 ms |
189
+ | needLayout | Boolean | false | 动画是否影响布局(仅 nvue) |
190
+ | transformOrigin | String | center center | transform-origin |
191
+
192
+ ### timingFunction 可选值 {#timing-function}
193
+
194
+ | 属性名 | 说明 |
195
+ | --- | --- |
196
+ | linear | 匀速 |
197
+ | ease | 低速开始、中间加速、结束变慢 |
198
+ | ease-in | 低速开始 |
199
+ | ease-in-out | 低速开始和结束 |
200
+ | ease-out | 低速结束 |
201
+ | step-start | 第一帧跳至结束(nvue 不支持) |
202
+ | step-end | 最后一帧跳到结束(nvue 不支持) |
@@ -0,0 +1,156 @@
1
+ ---
2
+ group: 表单
3
+ category: Components
4
+ title: Upload
5
+ subtitle: 上传
6
+ description: 用于上传图片、视频等,可配合 uv-form 进行校验。
7
+ demo:
8
+ cols: 2
9
+ ---
10
+
11
+ ## 何时使用 {#when-to-use}
12
+
13
+ `uv-upload` 通过 `fileList` 显示已上传文件,`afterRead` 处理选择后的上传逻辑,`delete` 处理删除。
14
+
15
+ > 完整示例下载地址:[uv-ui 插件市场](https://ext.dcloud.net.cn/plugin?name=uv-ui)
16
+
17
+ ## 平台兼容性 {#platform}
18
+
19
+ | App(vue) | App(nvue) | H5 | 小程序 | VUE2 | VUE3 |
20
+ | --- | --- | --- | --- | --- | --- |
21
+ | √ | √ | √ | √ | √ | √ |
22
+
23
+ **组件名:** `uv-upload`
24
+
25
+ ## 代码演示 {#examples}
26
+
27
+ ### 基础用法 {#basic}
28
+
29
+ ```vue
30
+ <template>
31
+ <uv-upload
32
+ :fileList="fileList1"
33
+ name="1"
34
+ multiple
35
+ :maxCount="10"
36
+ @afterRead="afterRead"
37
+ @delete="deletePic"
38
+ ></uv-upload>
39
+ </template>
40
+ <script>
41
+ export default {
42
+ data() {
43
+ return { fileList1: [] }
44
+ },
45
+ methods: {
46
+ deletePic(event) {
47
+ this[`fileList${event.name}`].splice(event.index, 1)
48
+ },
49
+ async afterRead(event) {
50
+ const lists = [].concat(event.file)
51
+ let fileListLen = this[`fileList${event.name}`].length
52
+ lists.forEach(item => {
53
+ this[`fileList${event.name}`].push({
54
+ ...item,
55
+ status: 'uploading',
56
+ message: '上传中'
57
+ })
58
+ })
59
+ for (let i = 0; i < lists.length; i++) {
60
+ const result = await this.uploadFilePromise(lists[i].url)
61
+ let item = this[`fileList${event.name}`][fileListLen]
62
+ this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
63
+ status: 'success',
64
+ message: '',
65
+ url: result
66
+ }))
67
+ fileListLen++
68
+ }
69
+ },
70
+ uploadFilePromise(url) {
71
+ return new Promise((resolve) => {
72
+ uni.uploadFile({
73
+ url: 'your-upload-api',
74
+ filePath: url,
75
+ name: 'file',
76
+ success: (res) => {
77
+ setTimeout(() => resolve(res.data.data), 1000)
78
+ }
79
+ })
80
+ })
81
+ }
82
+ }
83
+ }
84
+ </script>
85
+ ```
86
+
87
+ ### 上传视频 {#video}
88
+
89
+ ```vue
90
+ <uv-upload :fileList="[]" name="2" multiple :maxCount="10" accept="video"></uv-upload>
91
+ ```
92
+
93
+ ### 文件预览 {#preview}
94
+
95
+ ```vue
96
+ <uv-upload :fileList="fileList" name="3" multiple :maxCount="10" :previewFullImage="true"></uv-upload>
97
+ ```
98
+
99
+ ### 限制数量 {#max-count}
100
+
101
+ 达到 `maxCount` 时隐藏上传按钮。
102
+
103
+ ```vue
104
+ <uv-upload :fileList="fileList" :maxCount="1" multiple></uv-upload>
105
+ ```
106
+
107
+ ### 自定义上传样式 {#custom}
108
+
109
+ ```vue
110
+ <uv-upload :fileList="[]" name="6" :maxCount="1" width="250" height="150">
111
+ <image src="..." mode="widthFix" style="width: 250px;height: 150px;"></image>
112
+ </uv-upload>
113
+ ```
114
+
115
+ ## API {#api}
116
+
117
+ ### Upload Props {#props}
118
+
119
+ | 参数 | 说明 | 类型 | 默认值 |
120
+ | --- | --- | --- | --- |
121
+ | fileList | 已上传列表 | Array | - |
122
+ | accept | 接受类型 | String | image |
123
+ | capture | 拾取模式 | String \| Array | ['album','camera'] |
124
+ | maxCount | 最大数量 | String \| Number | 52 |
125
+ | multiple | 多选 | Boolean | false |
126
+ | deletable | 删除按钮 | Boolean | true |
127
+ | maxSize | 单文件最大大小 B | String \| Number | - |
128
+ | width | 宽度 rpx | String \| Number | 80 |
129
+ | height | 高度 rpx | String \| Number | 80 |
130
+ | previewFullImage | 图片预览 | Boolean | true |
131
+ | previewFullVideo | 视频预览 | Boolean | true |
132
+ | useBeforeRead | 是否用 beforeRead | Boolean | false |
133
+
134
+ ### FileList Options {#filelist}
135
+
136
+ | 属性名 | 说明 |
137
+ | --- | --- |
138
+ | status | uploading \| success \| failed |
139
+ | message | 提示文本 |
140
+ | url | 图片/文件地址 |
141
+
142
+ ### Upload Events {#events}
143
+
144
+ | 事件名 | 说明 | 回调参数 |
145
+ | --- | --- | --- |
146
+ | @beforeRead | 读取前(需 useBeforeRead) | file, lists, name |
147
+ | @afterRead | 读取后 | file, lists, name |
148
+ | @oversize | 超出最大尺寸 | file, lists, name |
149
+ | @clickPreview | 预览时 | e |
150
+ | @delete | 删除 | e={ file, index, name } |
151
+
152
+ ### Upload Slots {#slots}
153
+
154
+ | 名称 | 说明 |
155
+ | --- | --- |
156
+ | default | 自定义上传样式 |