@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.
- package/README.md +302 -0
- package/bin/cli.js +155 -0
- package/package.json +22 -0
- package/template/docs/uv-ui-docs/action-sheet-cn.md +180 -0
- package/template/docs/uv-ui-docs/album-cn.md +104 -0
- package/template/docs/uv-ui-docs/alert-cn.md +71 -0
- package/template/docs/uv-ui-docs/avatar-cn.md +149 -0
- package/template/docs/uv-ui-docs/back-top-cn.md +121 -0
- package/template/docs/uv-ui-docs/badge-cn.md +100 -0
- package/template/docs/uv-ui-docs/button-cn.md +181 -0
- package/template/docs/uv-ui-docs/calendar-cn.md +179 -0
- package/template/docs/uv-ui-docs/calendars-cn.md +264 -0
- package/template/docs/uv-ui-docs/cell-cn.md +163 -0
- package/template/docs/uv-ui-docs/checkbox-cn.md +164 -0
- package/template/docs/uv-ui-docs/code-cn.md +122 -0
- package/template/docs/uv-ui-docs/code-input-cn.md +127 -0
- package/template/docs/uv-ui-docs/collapse-cn.md +206 -0
- package/template/docs/uv-ui-docs/color-cn.md +122 -0
- package/template/docs/uv-ui-docs/count-down-cn.md +169 -0
- package/template/docs/uv-ui-docs/count-to-cn.md +125 -0
- package/template/docs/uv-ui-docs/datetime-picker-cn.md +167 -0
- package/template/docs/uv-ui-docs/divider-cn.md +90 -0
- package/template/docs/uv-ui-docs/drop-down-cn.md +287 -0
- package/template/docs/uv-ui-docs/empty-cn.md +76 -0
- package/template/docs/uv-ui-docs/form-cn.md +220 -0
- package/template/docs/uv-ui-docs/gap-cn.md +63 -0
- package/template/docs/uv-ui-docs/grid-cn.md +187 -0
- package/template/docs/uv-ui-docs/icon-cn.md +255 -0
- package/template/docs/uv-ui-docs/image-cn.md +170 -0
- package/template/docs/uv-ui-docs/index-list-cn.md +132 -0
- package/template/docs/uv-ui-docs/input-cn.md +157 -0
- package/template/docs/uv-ui-docs/keyboard-cn.md +156 -0
- package/template/docs/uv-ui-docs/layout-cn.md +215 -0
- package/template/docs/uv-ui-docs/line-cn.md +77 -0
- package/template/docs/uv-ui-docs/line-progress-cn.md +132 -0
- package/template/docs/uv-ui-docs/link-cn.md +97 -0
- package/template/docs/uv-ui-docs/list-cn.md +185 -0
- package/template/docs/uv-ui-docs/load-more-cn.md +144 -0
- package/template/docs/uv-ui-docs/loading-icon-cn.md +125 -0
- package/template/docs/uv-ui-docs/loading-page-cn.md +85 -0
- package/template/docs/uv-ui-docs/modal-cn.md +212 -0
- package/template/docs/uv-ui-docs/navbar-cn.md +171 -0
- package/template/docs/uv-ui-docs/no-network-cn.md +112 -0
- package/template/docs/uv-ui-docs/notice-bar-cn.md +119 -0
- package/template/docs/uv-ui-docs/notify-cn.md +185 -0
- package/template/docs/uv-ui-docs/number-box-cn.md +131 -0
- package/template/docs/uv-ui-docs/overlay-cn.md +122 -0
- package/template/docs/uv-ui-docs/parse-cn.md +177 -0
- package/template/docs/uv-ui-docs/pick-color-cn.md +147 -0
- package/template/docs/uv-ui-docs/picker-cn.md +159 -0
- package/template/docs/uv-ui-docs/popup-cn.md +184 -0
- package/template/docs/uv-ui-docs/qrcode-cn.md +150 -0
- package/template/docs/uv-ui-docs/radio-cn.md +166 -0
- package/template/docs/uv-ui-docs/rate-cn.md +91 -0
- package/template/docs/uv-ui-docs/read-more-cn.md +191 -0
- package/template/docs/uv-ui-docs/scroll-list-cn.md +188 -0
- package/template/docs/uv-ui-docs/search-cn.md +107 -0
- package/template/docs/uv-ui-docs/skeleton-cn.md +101 -0
- package/template/docs/uv-ui-docs/skeletons-cn.md +312 -0
- package/template/docs/uv-ui-docs/slider-cn.md +98 -0
- package/template/docs/uv-ui-docs/steps-cn.md +158 -0
- package/template/docs/uv-ui-docs/sticky-cn.md +82 -0
- package/template/docs/uv-ui-docs/subsection-cn.md +161 -0
- package/template/docs/uv-ui-docs/swipe-action-cn.md +207 -0
- package/template/docs/uv-ui-docs/swiper-cn.md +247 -0
- package/template/docs/uv-ui-docs/switch-cn.md +136 -0
- package/template/docs/uv-ui-docs/tabbar-cn.md +224 -0
- package/template/docs/uv-ui-docs/tabs-cn.md +260 -0
- package/template/docs/uv-ui-docs/tags-cn.md +191 -0
- package/template/docs/uv-ui-docs/text-cn.md +178 -0
- package/template/docs/uv-ui-docs/textarea-cn.md +132 -0
- package/template/docs/uv-ui-docs/toast-cn.md +110 -0
- package/template/docs/uv-ui-docs/tooltip-cn.md +91 -0
- package/template/docs/uv-ui-docs/transition-cn.md +202 -0
- package/template/docs/uv-ui-docs/upload-cn.md +156 -0
- package/template/docs/uv-ui-docs/vtabs-cn.md +190 -0
- package/template/docs/uv-ui-docs/waterfall-cn.md +276 -0
- package/template/rules/common.mdc +90 -0
- package/template/rules/uv-ui-docs.mdc +111 -0
- package/template/skills/code-simplifier/SKILL.md +109 -0
- package/template/skills/frontend-design/SKILL.md +44 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
---
|
|
2
|
+
group: 导航
|
|
3
|
+
category: Components
|
|
4
|
+
title: Steps
|
|
5
|
+
subtitle: 步骤条
|
|
6
|
+
description: 用于展示任务或流程的多个阶段,并高亮当前进度,支持横向/竖向、点状模式和错误状态。
|
|
7
|
+
demo:
|
|
8
|
+
cols: 2
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 何时使用 {#when-to-use}
|
|
12
|
+
|
|
13
|
+
`uv-steps` / `uv-steps-item` 一般用于 **多步骤流程** 的场景,例如下单流程、审批流程、物流进度等,用于标识当前处于第几步以及每一步的状态。
|
|
14
|
+
|
|
15
|
+
- 支持横向(row)和竖向(column)排布
|
|
16
|
+
- 支持点状步骤条(dot 模式)
|
|
17
|
+
- 支持错误状态展示
|
|
18
|
+
- 支持自定义图标与自定义内容
|
|
19
|
+
|
|
20
|
+
> 安卓 nvue 下 `overflow: visible` 不支持,因此该组件暂不支持安卓 nvue 环境。
|
|
21
|
+
> 完整示例下载地址:[uv-ui 插件市场](https://ext.dcloud.net.cn/plugin?name=uv-ui)
|
|
22
|
+
|
|
23
|
+
## 平台兼容性 {#platform}
|
|
24
|
+
|
|
25
|
+
| App(vue) | App(nvue) | H5 | 小程序 | VUE2 | VUE3 |
|
|
26
|
+
| --- | --- | --- | --- | --- | --- |
|
|
27
|
+
| √ | × | √ | √ | √ | √ |
|
|
28
|
+
|
|
29
|
+
**组件名:** `uv-steps`、`uv-steps-item`
|
|
30
|
+
|
|
31
|
+
## 代码演示 {#examples}
|
|
32
|
+
|
|
33
|
+
### 基本使用 {#basic}
|
|
34
|
+
|
|
35
|
+
通过 `current` 指定当前处于第几步(从 0 开始),内部使用多个 `uv-steps-item` 描述每一步。
|
|
36
|
+
|
|
37
|
+
```vue
|
|
38
|
+
<template>
|
|
39
|
+
<uv-steps current="0">
|
|
40
|
+
<uv-steps-item title="已下单" desc="10:30"></uv-steps-item>
|
|
41
|
+
<uv-steps-item title="已出库" desc="10:35"></uv-steps-item>
|
|
42
|
+
<uv-steps-item title="运输中" desc="11:40"></uv-steps-item>
|
|
43
|
+
</uv-steps>
|
|
44
|
+
</template>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 错误状态 {#error}
|
|
48
|
+
|
|
49
|
+
通过 `uv-steps-item` 的 `error` 属性标记失败步骤。
|
|
50
|
+
|
|
51
|
+
```vue
|
|
52
|
+
<template>
|
|
53
|
+
<uv-steps current="1">
|
|
54
|
+
<uv-steps-item title="已下单" desc="10:30"></uv-steps-item>
|
|
55
|
+
<uv-steps-item error title="仓库着火" desc="10:35"></uv-steps-item>
|
|
56
|
+
<uv-steps-item title="破产清算" desc="11:40"></uv-steps-item>
|
|
57
|
+
</uv-steps>
|
|
58
|
+
</template>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 点状模式 {#dot}
|
|
62
|
+
|
|
63
|
+
```vue
|
|
64
|
+
<template>
|
|
65
|
+
<uv-steps current="1" dot>
|
|
66
|
+
<uv-steps-item title="已下单" desc="10:30"></uv-steps-item>
|
|
67
|
+
<uv-steps-item title="已出库" desc="10:35"></uv-steps-item>
|
|
68
|
+
<uv-steps-item title="运输中" desc="11:40"></uv-steps-item>
|
|
69
|
+
</uv-steps>
|
|
70
|
+
</template>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 竖向模式 {#column}
|
|
74
|
+
|
|
75
|
+
```vue
|
|
76
|
+
<template>
|
|
77
|
+
<uv-steps current="1" direction="column">
|
|
78
|
+
<uv-steps-item title="已下单" desc="10:30"></uv-steps-item>
|
|
79
|
+
<uv-steps-item title="已出库" desc="10:35"></uv-steps-item>
|
|
80
|
+
<uv-steps-item title="运输中" desc="11:40"></uv-steps-item>
|
|
81
|
+
</uv-steps>
|
|
82
|
+
</template>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 自定义图标与颜色 {#custom-icon}
|
|
86
|
+
|
|
87
|
+
通过 `activeIcon` / `inactiveIcon` 设置步骤图标,也可以通过插槽 `icon` 自定义图标,并通过 `active-color` / `inactive-color` 控制线条颜色。
|
|
88
|
+
|
|
89
|
+
```vue
|
|
90
|
+
<template>
|
|
91
|
+
<uv-steps current="1" active-color="#3c9cff" inactive-color="#999">
|
|
92
|
+
<uv-steps-item title="已下单" desc="09:35">
|
|
93
|
+
<template v-slot:icon>
|
|
94
|
+
<uv-icon name="checkmark" color="#3c9cff"></uv-icon>
|
|
95
|
+
</template>
|
|
96
|
+
</uv-steps-item>
|
|
97
|
+
<uv-steps-item title="已出库" desc="10:35">
|
|
98
|
+
<template v-slot:icon>
|
|
99
|
+
<uv-icon name="checkmark" color="#3c9cff"></uv-icon>
|
|
100
|
+
</template>
|
|
101
|
+
</uv-steps-item>
|
|
102
|
+
<uv-steps-item title="运输中" desc="11:40"></uv-steps-item>
|
|
103
|
+
</uv-steps>
|
|
104
|
+
</template>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 自定义标题与描述插槽 {#custom-content}
|
|
108
|
+
|
|
109
|
+
```vue
|
|
110
|
+
<template>
|
|
111
|
+
<uv-steps current="1">
|
|
112
|
+
<uv-steps-item>
|
|
113
|
+
<template v-slot:title>
|
|
114
|
+
<text>已下单</text>
|
|
115
|
+
</template>
|
|
116
|
+
<template v-slot:desc>
|
|
117
|
+
<text>00:00</text>
|
|
118
|
+
</template>
|
|
119
|
+
</uv-steps-item>
|
|
120
|
+
<uv-steps-item title="已出库" desc="10:35"></uv-steps-item>
|
|
121
|
+
<uv-steps-item title="运输中" desc="11:40"></uv-steps-item>
|
|
122
|
+
</uv-steps>
|
|
123
|
+
</template>
|
|
124
|
+
``>
|
|
125
|
+
|
|
126
|
+
## API {#api}
|
|
127
|
+
|
|
128
|
+
### Steps Props {#steps-props}
|
|
129
|
+
|
|
130
|
+
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
|
131
|
+
| --- | --- | --- | --- | --- |
|
|
132
|
+
| direction | 步骤条方向:`row` 横向、`column` 竖向 | String | row | row \| column |
|
|
133
|
+
| current | 当前处于第几步(从 0 开始) | Number \| String | 0 | - |
|
|
134
|
+
| activeColor | 激活状态颜色 | String | #3c9cff | - |
|
|
135
|
+
| inactiveColor | 未激活状态颜色 | String | #969799 | - |
|
|
136
|
+
| activeIcon | 激活状态图标(不使用插槽时生效) | String | - | - |
|
|
137
|
+
| inactiveIcon | 未激活状态图标 | String | - | - |
|
|
138
|
+
| dot | 是否为点状步骤条 | Boolean | false | true \| false |
|
|
139
|
+
| customStyle | 自定义外部样式 | Object | - | - |
|
|
140
|
+
|
|
141
|
+
### StepsItem Props {#steps-item-props}
|
|
142
|
+
|
|
143
|
+
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
|
144
|
+
| --- | --- | --- | --- | --- |
|
|
145
|
+
| title | 标题文字 | String | - | - |
|
|
146
|
+
| desc | 描述文字 | String | - | - |
|
|
147
|
+
| iconSize | 图标大小(需 `uv-steps` 设置 `activeIcon` 或 `inactiveIcon`,单位 px/rpx) | String \| Number | 17 | - |
|
|
148
|
+
| error | 当前步骤是否为失败状态 | Boolean | false | true \| false |
|
|
149
|
+
| customStyle | 自定义外部样式(可用于调整 padding、间距等) | Object | - | - |
|
|
150
|
+
|
|
151
|
+
### StepsItem Slots {#steps-item-slots}
|
|
152
|
+
|
|
153
|
+
| 名称 | 说明 |
|
|
154
|
+
| --- | --- |
|
|
155
|
+
| icon | 自定义图标 |
|
|
156
|
+
| title | 自定义标题内容 |
|
|
157
|
+
| desc | 自定义描述内容 |
|
|
158
|
+
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
group: 布局
|
|
3
|
+
category: Components
|
|
4
|
+
title: Sticky
|
|
5
|
+
subtitle: 吸顶
|
|
6
|
+
description: 提供与 CSS position: sticky 类似的吸顶效果,当内容滚动到指定位置时将组件固定在顶部。
|
|
7
|
+
demo:
|
|
8
|
+
cols: 2
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 何时使用 {#when-to-use}
|
|
12
|
+
|
|
13
|
+
`uv-sticky` 用于 **内容滚动到一定位置后固定在顶部** 的场景,例如吸顶 Tabs、固定筛选条等。
|
|
14
|
+
|
|
15
|
+
- 内部自动检测当前环境是否支持 CSS `position: sticky`
|
|
16
|
+
- 支持 H5、App、nvue、小程序多端,并在不支持 sticky 时自动降级为 JS 方案
|
|
17
|
+
- 通过 `offsetTop` 控制吸顶时距离顶部的偏移
|
|
18
|
+
|
|
19
|
+
> 建议将 `uv-sticky` 放在页面 **外层容器** 中,以避免因层级嵌套导致 sticky 失效。
|
|
20
|
+
> 完整示例下载地址:[uv-ui 插件市场](https://ext.dcloud.net.cn/plugin?name=uv-ui)
|
|
21
|
+
|
|
22
|
+
## 平台兼容性 {#platform}
|
|
23
|
+
|
|
24
|
+
| App(vue) | App(nvue) | H5 | 小程序 | VUE2 | VUE3 |
|
|
25
|
+
| --- | --- | --- | --- | --- | --- |
|
|
26
|
+
| √ | √ | √ | √ | √ | √ |
|
|
27
|
+
|
|
28
|
+
**组件名:** `uv-sticky`
|
|
29
|
+
|
|
30
|
+
## 代码演示 {#examples}
|
|
31
|
+
|
|
32
|
+
### 基本使用 {#basic}
|
|
33
|
+
|
|
34
|
+
```vue
|
|
35
|
+
<template>
|
|
36
|
+
<view class="container">
|
|
37
|
+
<!-- 建议放在外层 -->
|
|
38
|
+
<uv-sticky>
|
|
39
|
+
<text>吸顶内容</text>
|
|
40
|
+
</uv-sticky>
|
|
41
|
+
|
|
42
|
+
<view class="container__inner">
|
|
43
|
+
<!-- 如非必要,不建议层层嵌套 sticky -->
|
|
44
|
+
<uv-sticky>......</uv-sticky>
|
|
45
|
+
</view>
|
|
46
|
+
</view>
|
|
47
|
+
</template>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 吸顶距离 {#offset-top}
|
|
51
|
+
|
|
52
|
+
通过 `offsetTop` 设置组件在吸顶时与顶部的距离(px/rpx)。
|
|
53
|
+
|
|
54
|
+
```vue
|
|
55
|
+
<uv-sticky offset-top="20">
|
|
56
|
+
<text>塞下秋来风景异,衡阳雁去无留意</text>
|
|
57
|
+
</uv-sticky>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 自定义导航栏高度 {#custom-nav-height}
|
|
61
|
+
|
|
62
|
+
在使用自定义导航栏(如 `uv-navbar`)时,可以通过 `customNavHeight` 告诉 sticky 当前导航栏高度,避免遮挡。
|
|
63
|
+
|
|
64
|
+
```vue
|
|
65
|
+
<uv-sticky :customNavHeight="44">
|
|
66
|
+
<uv-tabs :list="list"></uv-tabs>
|
|
67
|
+
</uv-sticky>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## API {#api}
|
|
71
|
+
|
|
72
|
+
### Sticky Props {#props}
|
|
73
|
+
|
|
74
|
+
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
|
75
|
+
| --- | --- | --- | --- | --- |
|
|
76
|
+
| offsetTop | 吸顶时与顶部的距离(px/rpx) | String \| Number | 0 | - |
|
|
77
|
+
| customNavHeight | 自定义导航栏高度,用于与导航栏配合使用 | String \| Number | 0 | - |
|
|
78
|
+
| disabled | 是否禁用吸顶功能 | Boolean | false | true \| false |
|
|
79
|
+
| bgColor | 组件背景颜色 | String | #ffffff | - |
|
|
80
|
+
| zIndex | 吸顶时的 z-index(nvue 无效) | String \| Number | - | - |
|
|
81
|
+
| index | 自定义标识,用于区分多个 sticky 组件 | String \| Number | - | - |
|
|
82
|
+
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
---
|
|
2
|
+
group: 导航
|
|
3
|
+
category: Components
|
|
4
|
+
title: Subsection
|
|
5
|
+
subtitle: 分段器
|
|
6
|
+
description: 在多个选项之间进行单选切换的分段器组件,支持按钮模式和分段模式,以及颜色和样式自定义。
|
|
7
|
+
demo:
|
|
8
|
+
cols: 2
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 何时使用 {#when-to-use}
|
|
12
|
+
|
|
13
|
+
`uv-subsection` 适用于 **从若干选项中选择一个** 的场景,例如订单状态切换、筛选条件切换等。
|
|
14
|
+
|
|
15
|
+
- 使用 `list` 配置选项
|
|
16
|
+
- 通过 `current` 控制当前激活项
|
|
17
|
+
- 支持按钮模式与分段器模式
|
|
18
|
+
- 支持文字颜色、背景色与圆角样式定制
|
|
19
|
+
|
|
20
|
+
> 在弹窗等场景中若显示异常,需要使用 `v-if` 控制挂载时机。
|
|
21
|
+
> 完整示例下载地址:[uv-ui 插件市场](https://ext.dcloud.net.cn/plugin?name=uv-ui)
|
|
22
|
+
|
|
23
|
+
## 平台兼容性 {#platform}
|
|
24
|
+
|
|
25
|
+
| App(vue) | App(nvue) | H5 | 小程序 | VUE2 | VUE3 |
|
|
26
|
+
| --- | --- | --- | --- | --- | --- |
|
|
27
|
+
| √ | √ | √ | √ | √ | √ |
|
|
28
|
+
|
|
29
|
+
**组件名:** `uv-subsection`
|
|
30
|
+
|
|
31
|
+
## 代码演示 {#examples}
|
|
32
|
+
|
|
33
|
+
### 基本使用 {#basic}
|
|
34
|
+
|
|
35
|
+
`list` 可直接使用字符串数组,也可以通过对象 + `keyName` 的方式配置;通过 `current` 指定初始选中索引。
|
|
36
|
+
|
|
37
|
+
```vue
|
|
38
|
+
<template>
|
|
39
|
+
<uv-subsection :list="list" :current="current" @change="change"></uv-subsection>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script>
|
|
43
|
+
export default {
|
|
44
|
+
data() {
|
|
45
|
+
return {
|
|
46
|
+
list: ['未付款', '待评价', '已付款'],
|
|
47
|
+
// 或者:
|
|
48
|
+
// list: [{ name: '未付款' }, { name: '待评价' }, { name: '已付款' }],
|
|
49
|
+
current: 1
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
methods: {
|
|
53
|
+
change(index) {
|
|
54
|
+
this.current = index
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
</script>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 模式选择 {#mode}
|
|
62
|
+
|
|
63
|
+
通过 `mode` 切换展示模式:
|
|
64
|
+
|
|
65
|
+
- `button`:按钮类型(默认)
|
|
66
|
+
- `subsection`:经典分段器形式
|
|
67
|
+
|
|
68
|
+
```vue
|
|
69
|
+
<uv-subsection :list="list" mode="subsection" :current="current" @change="change"></uv-subsection>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 颜色配置 {#color}
|
|
73
|
+
|
|
74
|
+
可配置激活/未激活文字颜色及背景色(`mode="button"` 有效)。
|
|
75
|
+
|
|
76
|
+
```vue
|
|
77
|
+
<template>
|
|
78
|
+
<uv-subsection
|
|
79
|
+
:list="list"
|
|
80
|
+
mode="button"
|
|
81
|
+
:current="current"
|
|
82
|
+
activeColor="#f56c6c"
|
|
83
|
+
inactiveColor="#a9e08f"
|
|
84
|
+
bgColor="#f56c6c"
|
|
85
|
+
@change="change"
|
|
86
|
+
></uv-subsection>
|
|
87
|
+
</template>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 自定义样式与圆角 {#custom-style}
|
|
91
|
+
|
|
92
|
+
通过 `custom-style` / `custom-item-style` 控制整体和子项样式,例如设置高度与圆角。
|
|
93
|
+
|
|
94
|
+
```vue
|
|
95
|
+
<template>
|
|
96
|
+
<uv-subsection
|
|
97
|
+
:list="list"
|
|
98
|
+
:current="current"
|
|
99
|
+
custom-style="height: 60rpx;border-radius: 30rpx;"
|
|
100
|
+
custom-item-style="border-radius: 30rpx;"
|
|
101
|
+
@change="change"
|
|
102
|
+
></uv-subsection>
|
|
103
|
+
</template>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 注意事项(双向绑定) {#note}
|
|
107
|
+
|
|
108
|
+
若使用变量绑定 `current`,需要在 `change` 回调中同步更新该值;否则前后两次设置同一值可能无法触发视图更新。
|
|
109
|
+
|
|
110
|
+
```vue
|
|
111
|
+
<template>
|
|
112
|
+
<uv-subsection :list="list" :current="current" @change="change"></uv-subsection>
|
|
113
|
+
</template>
|
|
114
|
+
|
|
115
|
+
<script>
|
|
116
|
+
export default {
|
|
117
|
+
data() {
|
|
118
|
+
return {
|
|
119
|
+
list: ['未付款', '待评价', '已付款'],
|
|
120
|
+
current: 0
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
methods: {
|
|
124
|
+
change(index) {
|
|
125
|
+
this.current = index
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
</script>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## API {#api}
|
|
133
|
+
|
|
134
|
+
### Subsection Props {#props}
|
|
135
|
+
|
|
136
|
+
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
|
137
|
+
| --- | --- | --- | --- | --- |
|
|
138
|
+
| list | 选项数组(字符串或对象),格式见上方“基本使用” | Array | - | - |
|
|
139
|
+
| keyName | 从对象中读取 label 的键名 | String | name | - |
|
|
140
|
+
| current | 初始化默认选中项索引 | String \| Number | 0 | - |
|
|
141
|
+
| activeColor | 激活项文字颜色 | String | #3c9cff | - |
|
|
142
|
+
| inactiveColor | 未激活项文字颜色 | String | #303133 | - |
|
|
143
|
+
| mode | 展示模式 | String | button | button \| subsection |
|
|
144
|
+
| fontSize | 字体大小(px/rpx) | String \| Number | 12 | - |
|
|
145
|
+
| bold | 激活项文字是否加粗 | Boolean | true | true \| false |
|
|
146
|
+
| bgColor | 背景颜色(`mode="button"` 有效) | String | #eeeeef | - |
|
|
147
|
+
| customStyle | 自定义外层样式 | String \| Object | - | - |
|
|
148
|
+
| customItemStyle | 自定义子项样式 | String \| Object | - | - |
|
|
149
|
+
|
|
150
|
+
### Methods {#methods}
|
|
151
|
+
|
|
152
|
+
| 方法名 | 说明 | 参数 |
|
|
153
|
+
| --- | --- | --- |
|
|
154
|
+
| init | 初始化组件(在弹窗等场景中,打开时可调用以修正计算误差) | - |
|
|
155
|
+
|
|
156
|
+
### Events {#events}
|
|
157
|
+
|
|
158
|
+
| 事件名 | 说明 | 回调参数 |
|
|
159
|
+
| --- | --- | --- |
|
|
160
|
+
| change | 分段器选项发生改变时触发 | index:选项索引,从 0 开始 |
|
|
161
|
+
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
---
|
|
2
|
+
group: 反馈
|
|
3
|
+
category: Components
|
|
4
|
+
title: SwipeAction
|
|
5
|
+
subtitle: 滑动单元格
|
|
6
|
+
description: 左滑唤出操作菜单的单元格组件,支持多按钮、组合列表、自动关闭等能力。
|
|
7
|
+
demo:
|
|
8
|
+
cols: 2
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 何时使用 {#when-to-use}
|
|
12
|
+
|
|
13
|
+
`uv-swipe-action` 一般用于左滑唤出操作菜单的场景,如左滑删除、置顶、更多操作等。
|
|
14
|
+
|
|
15
|
+
注意:
|
|
16
|
+
|
|
17
|
+
- 如通过 `v-for` 用于左滑删除列表,请确保循环的 `:key` 为唯一值(如 id、title),不要使用 index,避免删除时数据错乱。
|
|
18
|
+
|
|
19
|
+
> 完整示例下载地址:[uv-ui 插件市场](https://ext.dcloud.net.cn/plugin?name=uv-ui)
|
|
20
|
+
|
|
21
|
+
## 平台兼容性 {#platform}
|
|
22
|
+
|
|
23
|
+
| App(vue) | App(nvue) | H5 | 小程序 | VUE2 | VUE3 |
|
|
24
|
+
| --- | --- | --- | --- | --- | --- |
|
|
25
|
+
| √ | √ | √ | √(仅微信/QQ 小程序) | √ | √ |
|
|
26
|
+
|
|
27
|
+
**组件名:** `uv-swipe-action`、`uv-swipe-action-item`
|
|
28
|
+
|
|
29
|
+
## 代码演示 {#examples}
|
|
30
|
+
|
|
31
|
+
### 基本使用 {#basic}
|
|
32
|
+
|
|
33
|
+
通过 slot 传入内部内容,通过 `options` 配置右侧按钮。
|
|
34
|
+
|
|
35
|
+
```vue
|
|
36
|
+
<template>
|
|
37
|
+
<view>
|
|
38
|
+
<uv-swipe-action>
|
|
39
|
+
<uv-swipe-action-item :options="options">
|
|
40
|
+
<view class="swipe-action uv-border-top uv-border-bottom">
|
|
41
|
+
<view class="swipe-action__content">
|
|
42
|
+
<text class="swipe-action__content__text">基础使用</text>
|
|
43
|
+
</view>
|
|
44
|
+
</view>
|
|
45
|
+
</uv-swipe-action-item>
|
|
46
|
+
</uv-swipe-action>
|
|
47
|
+
</view>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<script>
|
|
51
|
+
export default {
|
|
52
|
+
data() {
|
|
53
|
+
return {
|
|
54
|
+
options: [
|
|
55
|
+
{
|
|
56
|
+
text: '删除',
|
|
57
|
+
style: {
|
|
58
|
+
backgroundColor: '#f56c6c'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<style lang="scss">
|
|
68
|
+
.uv-page {
|
|
69
|
+
padding: 0;
|
|
70
|
+
}
|
|
71
|
+
.uv-demo-block__title {
|
|
72
|
+
padding: 10px 0 2px 15px;
|
|
73
|
+
}
|
|
74
|
+
.swipe-action {
|
|
75
|
+
&__content {
|
|
76
|
+
padding: 25rpx 0;
|
|
77
|
+
&__text {
|
|
78
|
+
font-size: 15px;
|
|
79
|
+
color: #222;
|
|
80
|
+
padding-left: 30rpx;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
</style>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 多个按钮并列 {#multi-buttons}
|
|
88
|
+
|
|
89
|
+
```vue
|
|
90
|
+
<template>
|
|
91
|
+
<view>
|
|
92
|
+
<uv-swipe-action>
|
|
93
|
+
<uv-swipe-action-item :options="options">
|
|
94
|
+
<view class="swipe-action uv-border-top uv-border-bottom">
|
|
95
|
+
<view class="swipe-action__content">
|
|
96
|
+
<text class="swipe-action__content__text">两个按钮并列</text>
|
|
97
|
+
</view>
|
|
98
|
+
</view>
|
|
99
|
+
</uv-swipe-action-item>
|
|
100
|
+
</uv-swipe-action>
|
|
101
|
+
</view>
|
|
102
|
+
</template>
|
|
103
|
+
|
|
104
|
+
<script>
|
|
105
|
+
export default {
|
|
106
|
+
data() {
|
|
107
|
+
return {
|
|
108
|
+
options: [
|
|
109
|
+
{
|
|
110
|
+
text: '收藏',
|
|
111
|
+
style: { backgroundColor: '#3c9cff' }
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
text: '删除',
|
|
115
|
+
style: { backgroundColor: '#f56c6c' }
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
</script>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 组合使用 {#group}
|
|
125
|
+
|
|
126
|
+
支持在一个 `uv-swipe-action` 内渲染多个 `uv-swipe-action-item`,并为每行配置不同按钮组、禁用状态等。
|
|
127
|
+
|
|
128
|
+
```vue
|
|
129
|
+
<template>
|
|
130
|
+
<view>
|
|
131
|
+
<uv-swipe-action>
|
|
132
|
+
<uv-swipe-action-item
|
|
133
|
+
v-for="(item, index) in options"
|
|
134
|
+
:key="index"
|
|
135
|
+
:options="item.options"
|
|
136
|
+
:disabled="item.disabled"
|
|
137
|
+
>
|
|
138
|
+
<view class="swipe-action uv-border-top" :class="[index === options.length - 1 && 'uv-border-bottom']">
|
|
139
|
+
<view class="swipe-action__content">
|
|
140
|
+
<text class="swipe-action__content__text">{{ item.text }}</text>
|
|
141
|
+
</view>
|
|
142
|
+
</view>
|
|
143
|
+
</uv-swipe-action-item>
|
|
144
|
+
</uv-swipe-action>
|
|
145
|
+
</view>
|
|
146
|
+
</template>
|
|
147
|
+
|
|
148
|
+
<script>
|
|
149
|
+
export default {
|
|
150
|
+
data() {
|
|
151
|
+
return {
|
|
152
|
+
options: [
|
|
153
|
+
{
|
|
154
|
+
text: '禁用状态',
|
|
155
|
+
disabled: true,
|
|
156
|
+
options: [
|
|
157
|
+
{ text: '置顶', style: { backgroundColor: '#3c9cff' } },
|
|
158
|
+
{ text: '取消', style: { backgroundColor: '#f9ae3d' } }
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
text: '正常状态',
|
|
163
|
+
disabled: false,
|
|
164
|
+
options: [
|
|
165
|
+
{ text: '置顶', style: { backgroundColor: '#3c9cff' } },
|
|
166
|
+
{ text: '取消', style: { backgroundColor: '#f9ae3d' } }
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
</script>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## API {#api}
|
|
177
|
+
|
|
178
|
+
### SwipeAction Props {#action-props}
|
|
179
|
+
|
|
180
|
+
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
|
181
|
+
| --- | --- | --- | --- | --- |
|
|
182
|
+
| autoClose | 是否自动关闭其他 `swipe` 按钮组 | Boolean | true | true \| false |
|
|
183
|
+
|
|
184
|
+
### SwipeAction Events {#action-events}
|
|
185
|
+
|
|
186
|
+
| 事件名 | 说明 | 回调参数 |
|
|
187
|
+
| --- | --- | --- |
|
|
188
|
+
| @click | 点击组件时触发 | index |
|
|
189
|
+
|
|
190
|
+
### SwipeActionItem Props {#item-props}
|
|
191
|
+
|
|
192
|
+
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
|
193
|
+
| --- | --- | --- | --- | --- |
|
|
194
|
+
| show | 控制当前项打开/关闭 | Boolean | false | true \| false |
|
|
195
|
+
| index | 标识符(如 v-for 索引) | String \| Number | - | - |
|
|
196
|
+
| disabled | 是否禁用 | Boolean | false | true \| false |
|
|
197
|
+
| autoClose | 是否自动关闭其他 `swipe` 按钮组 | Boolean | true | true \| false |
|
|
198
|
+
| threshold | 滑动距离阈值(大于此值才认为打开菜单) | Number | 20 | - |
|
|
199
|
+
| options | 右侧按钮配置数组 | Array | [] | - |
|
|
200
|
+
| duration | 动画过渡时间(ms) | String \| Number | 300 | - |
|
|
201
|
+
| name | 标识符(如 v-for 索引) | String \| Number | - | - |
|
|
202
|
+
|
|
203
|
+
### SwipeActionItem Events {#item-events}
|
|
204
|
+
|
|
205
|
+
| 事件名 | 说明 | 回调参数 |
|
|
206
|
+
| --- | --- | --- |
|
|
207
|
+
| @click | 按钮被点击时触发 | name:props.name 值;index:第几个按钮被点击 |
|