@gmcb/uv-ui 0.2.26 → 0.3.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 (137) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +21 -21
  3. package/README.md +95 -141
  4. package/components/uv-overlay/props.js +29 -24
  5. package/components/uv-overlay/uv-overlay.vue +87 -85
  6. package/docs/api/configs/color.md +52 -0
  7. package/docs/api/index.md +77 -0
  8. package/docs/api/mixins/mpShare.md +95 -0
  9. package/docs/api/request/apiManage.md +88 -0
  10. package/docs/api/request/http.md +451 -0
  11. package/docs/api/utils/colorSwitch.md +78 -0
  12. package/docs/api/utils/debounce.md +104 -0
  13. package/docs/api/utils/fastUse.md +246 -0
  14. package/docs/api/utils/getRect.md +238 -0
  15. package/docs/api/utils/guid.md +41 -0
  16. package/docs/api/utils/index.md +55 -0
  17. package/docs/api/utils/intro.md +25 -0
  18. package/docs/api/utils/object.md +171 -0
  19. package/docs/api/utils/queryParams.md +68 -0
  20. package/docs/api/utils/random.md +23 -0
  21. package/docs/api/utils/randomArray.md +28 -0
  22. package/docs/api/utils/route.md +121 -0
  23. package/docs/api/utils/test.md +237 -0
  24. package/docs/api/utils/time.md +81 -0
  25. package/docs/api/utils/trim.md +24 -0
  26. package/docs/components/actionSheet.md +236 -0
  27. package/docs/components/addQQGroup.md +5 -0
  28. package/docs/components/album.md +91 -0
  29. package/docs/components/alert.md +83 -0
  30. package/docs/components/avatar.md +152 -0
  31. package/docs/components/backTop.md +181 -0
  32. package/docs/components/badge.md +117 -0
  33. package/docs/components/button.md +196 -0
  34. package/docs/components/calendar.md +398 -0
  35. package/docs/components/calendars.md +294 -0
  36. package/docs/components/cell.md +185 -0
  37. package/docs/components/checkbox.md +281 -0
  38. package/docs/components/circleProgress.md +5 -0
  39. package/docs/components/code.md +162 -0
  40. package/docs/components/codeInput.md +175 -0
  41. package/docs/components/collapse.md +250 -0
  42. package/docs/components/color.md +324 -0
  43. package/docs/components/common.md +126 -0
  44. package/docs/components/countDown.md +166 -0
  45. package/docs/components/countTo.md +140 -0
  46. package/docs/components/datetimePicker.md +283 -0
  47. package/docs/components/diff1.x.md +190 -0
  48. package/docs/components/divider.md +88 -0
  49. package/docs/components/downloadSetting.md +54 -0
  50. package/docs/components/dropDown.md +375 -0
  51. package/docs/components/empty.md +99 -0
  52. package/docs/components/feature.md +261 -0
  53. package/docs/components/form.md +736 -0
  54. package/docs/components/gap.md +49 -0
  55. package/docs/components/grid.md +225 -0
  56. package/docs/components/icon.md +101 -0
  57. package/docs/components/image.md +182 -0
  58. package/docs/components/index.md +110 -0
  59. package/docs/components/indexList.md +133 -0
  60. package/docs/components/input.md +250 -0
  61. package/docs/components/install.md +59 -0
  62. package/docs/components/intro.md +32 -0
  63. package/docs/components/keyboard.md +226 -0
  64. package/docs/components/layout.md +310 -0
  65. package/docs/components/line.md +85 -0
  66. package/docs/components/lineProgress.md +141 -0
  67. package/docs/components/link.md +89 -0
  68. package/docs/components/list.md +223 -0
  69. package/docs/components/loadMore.md +140 -0
  70. package/docs/components/loadingIcon.md +144 -0
  71. package/docs/components/loadingPage.md +92 -0
  72. package/docs/components/modal.md +230 -0
  73. package/docs/components/more.md +13 -0
  74. package/docs/components/navbar.md +192 -0
  75. package/docs/components/noNetwork.md +116 -0
  76. package/docs/components/noticeBar.md +131 -0
  77. package/docs/components/notify.md +204 -0
  78. package/docs/components/npmSetting.md +64 -0
  79. package/docs/components/numberBox.md +257 -0
  80. package/docs/components/nvue.md +170 -0
  81. package/docs/components/overlay.md +117 -0
  82. package/docs/components/parse.md +204 -0
  83. package/docs/components/pickColor.md +112 -0
  84. package/docs/components/picker.md +357 -0
  85. package/docs/components/popup.md +221 -0
  86. package/docs/components/problem.md +300 -0
  87. package/docs/components/qrcode.md +169 -0
  88. package/docs/components/quickstart.md +33 -0
  89. package/docs/components/radio.md +256 -0
  90. package/docs/components/rate.md +128 -0
  91. package/docs/components/read.md +163 -0
  92. package/docs/components/readMore.md +227 -0
  93. package/docs/components/resource.md +17 -0
  94. package/docs/components/scrollList.md +218 -0
  95. package/docs/components/search.md +160 -0
  96. package/docs/components/setting.md +111 -0
  97. package/docs/components/settingDesc.md +66 -0
  98. package/docs/components/skeleton.md +105 -0
  99. package/docs/components/skeletons.md +323 -0
  100. package/docs/components/slider.md +157 -0
  101. package/docs/components/steps.md +189 -0
  102. package/docs/components/sticky.md +76 -0
  103. package/docs/components/subsection.md +183 -0
  104. package/docs/components/swipeAction.md +279 -0
  105. package/docs/components/swiper.md +352 -0
  106. package/docs/components/switch.md +216 -0
  107. package/docs/components/tabbar.md +263 -0
  108. package/docs/components/table.md +5 -0
  109. package/docs/components/tabs.md +364 -0
  110. package/docs/components/tag.md +227 -0
  111. package/docs/components/testPic.md +20 -0
  112. package/docs/components/text.md +157 -0
  113. package/docs/components/textarea.md +121 -0
  114. package/docs/components/toast.md +124 -0
  115. package/docs/components/tooltip.md +98 -0
  116. package/docs/components/transition.md +404 -0
  117. package/docs/components/upload.md +253 -0
  118. package/docs/components/vtabs.md +332 -0
  119. package/docs/components/vueUse.md +45 -0
  120. package/docs/components/vuexDetail.md +103 -0
  121. package/docs/components/waterfall.md +651 -0
  122. package/docs/faq/index.md +53 -0
  123. package/docs/guide/codeHint.md +44 -0
  124. package/docs/guide/customIcon.md +168 -0
  125. package/docs/guide/demo.md +92 -0
  126. package/docs/guide/design.md +56 -0
  127. package/docs/guide/globalVariable.md +239 -0
  128. package/docs/guide/i18n.md +194 -0
  129. package/docs/guide/index.md +28 -0
  130. package/docs/guide/note.md +74 -0
  131. package/docs/guide/safeAreaInset.md +64 -0
  132. package/docs/guide/theme.md +67 -0
  133. package/docs/index.md +88 -0
  134. package/libs/config/config.js +0 -10
  135. package/libs/css/color.scss +15 -14
  136. package/package.json +7 -2
  137. package/theme.scss +2 -1
@@ -0,0 +1,157 @@
1
+ ## Slider 滑动选择器 <to-api/>
2
+
3
+ <demo-model url="/pages/componentsB/slider/slider"></demo-model>
4
+
5
+ ::: tip ✈
6
+
7
+ **组件名:uv-slider**
8
+
9
+ [点击下载&安装](https://ext.dcloud.net.cn/plugin?name=uv-slider)
10
+
11
+ :::
12
+
13
+ 该组件一般用于表单中,手动选择一个区间范围的场景。
14
+
15
+ **注意:** 该组件在```H5```,```微信小程序```和```APP-VUE```等平台上使用了```WXS```技术,在```NVUE```平台使用了```BindingX```技术,
16
+ 故在滑动过程中可以获得细腻流畅的跟随效果。
17
+
18
+ ### 平台兼容性
19
+
20
+ |App(vue)|App(nvue)|H5|小程序|VUE2|VUE3|
21
+ |:-:|:-:|:-:|:-:|:-:|:-:|
22
+ |√|√|√|√|√|√|
23
+
24
+ ### 基本使用
25
+
26
+ 需要通过`v-model`绑定一个值,来初始化滑块的选择值(0到100之间),这个值是双向绑定的,您可以通过这个值,实时地得知内部的滑动结果。
27
+
28
+
29
+ ```vue
30
+ <template>
31
+ <uv-slider v-model="value"></uv-slider>
32
+ </template>
33
+ <script setup>
34
+ import { ref } from 'vue';
35
+
36
+ const value = ref(30);
37
+
38
+ </script>
39
+ ```
40
+
41
+ ### 设置最大和最小值
42
+
43
+ 通过`min`和`max`,可以设置滑块所能选择的最大和最小值
44
+
45
+ ```vue
46
+ <template>
47
+ <uv-slider v-model="value" min="30" max="80"></uv-slider>
48
+ </template>
49
+ <script setup>
50
+ import { ref } from 'vue';
51
+
52
+ const value = ref(40);
53
+
54
+ </script>
55
+ ```
56
+
57
+ ### 设置步进值
58
+
59
+ 通过`step`参数设置步进值,这个步进值为每次跳变的值,具体表现请见示例。
60
+
61
+ :::warning 注意
62
+ `step`必须要被`max`值整除,否则会出现无法无法滑动到最大值的情况
63
+ :::
64
+
65
+ ```vue
66
+ <template>
67
+ <uv-slider v-model="value" step="10" min="30" max="100"></uv-slider>
68
+ </template>
69
+ <script setup>
70
+ import { ref } from 'vue';
71
+
72
+ const value = ref(40);
73
+
74
+ </script>
75
+ ```
76
+
77
+ ### 禁用状态
78
+
79
+ ```vue
80
+ <template>
81
+ <uv-slider v-model="value" disabled></uv-slider>
82
+ </template>
83
+ <script setup>
84
+ import { ref } from 'vue';
85
+
86
+ const value = ref(40);
87
+
88
+ </script>
89
+ ```
90
+
91
+ ### 设置滑块和线条的样式
92
+
93
+ - 通过`block-size`属性 设置滑块大小(高等于宽)
94
+ - 通过`block-color`属性 设置滑动按钮的颜色
95
+ - 通过`activeColor`属性 设置滑块左侧已选择部分的线条颜色
96
+ - 通过`backgroundColor`属性 设置滑块右侧背景条的颜色
97
+
98
+ ```vue
99
+ <template>
100
+ <uv-slider
101
+ v-model="value"
102
+ block-size="30"
103
+ block-color="red"
104
+ backgroundColor="pink"
105
+ activeColor="blue">
106
+ </uv-slider>
107
+ </template>
108
+ <script setup>
109
+ import { ref } from 'vue';
110
+
111
+ const value = ref(30);
112
+
113
+ </script>
114
+ ```
115
+
116
+ ### 完整示例
117
+
118
+ ::: tip 完整示例下载地址
119
+
120
+ [https://ext.dcloud.net.cn/plugin?name=uv-ui](https://ext.dcloud.net.cn/plugin?name=uv-ui)
121
+
122
+ :::
123
+
124
+ ### API
125
+ ---
126
+
127
+ ### Slider Props
128
+
129
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 |
130
+ |:- |:- |:- |:- |:- |
131
+ | value / v-model | 双向绑定滑块选择值 | String &#124; Number | 0 | - |
132
+ | min | 可选的最小值(0-100之间) | String &#124; Number | 1 | - |
133
+ | max | 可选的最大值(0-100之间) | String &#124; Number | 100 | - |
134
+ | step | 选择的步长 | String &#124; Number | 1 | - |
135
+ | activeColor | 滑块左侧已选择部分的线条颜色 | String | #2979ff | - |
136
+ | backgroundColor | 滑块右侧背景条的颜色 | String | #c0c4cc | - |
137
+ | block-size | 滑块的大小,取值范围为 12 - 28 | String &#124; Number | 18 | 12 - 28 |
138
+ | block-color | 滑块的颜色 | String | #ffffff | - |
139
+ | show-value | 是否显示当前 value | Boolean | false | true &#124; false |
140
+ | blockStyle | 滑块按钮自定义样式 | Object &#124; String | - | - |
141
+ | customStyle | 自定义外部样式 | Object | - | - |
142
+
143
+
144
+ ### Slider Events
145
+
146
+ | 事件名 | 说明 | 回调参数 |
147
+ | :- | :- | :- |
148
+ | @input| 更新v-model的(拖动过程中) | value:当前值 |
149
+ | @changing | 触发事件(拖动过程中) | value:当前值 |
150
+ | @change | 触发事件 | value:当前值 |
151
+
152
+
153
+ <style >
154
+ h3[id=slider-events] + table thead tr th:nth-child(2){
155
+ width: 40%;
156
+ }
157
+ </style>
@@ -0,0 +1,189 @@
1
+ ## Steps 步骤条 <to-api/>
2
+
3
+ <demo-model url="/pages/componentsD/steps/steps"></demo-model>
4
+
5
+ ::: tip ✈
6
+
7
+ **组件名:uv-steps > uv-steps-item**
8
+
9
+ [点击下载&安装](https://ext.dcloud.net.cn/plugin?name=uv-steps)
10
+
11
+ :::
12
+
13
+ 该组件一般用于完成一个任务要分几个步骤,标识目前处于第几步的场景。
14
+
15
+ ### 平台兼容性
16
+
17
+ |App(vue)|App(nvue)|H5|小程序|VUE2|VUE3|
18
+ |:-:|:-:|:-:|:-:|:-:|:-:|
19
+ |√|×|√|√|√|√|
20
+
21
+ :::warning 说明
22
+ 由于安卓`nvue`下,`overflow`属性不支持`visible`值,故此组件暂不支持安卓`nvue`环境。
23
+ :::
24
+
25
+ ### 基本使用
26
+
27
+ - 该组件需要`uv-steps`和`uv-steps-item`配合使用
28
+ - 通过`current`属性标识目前处于第几步,从0开始
29
+
30
+ ```vue
31
+ <template>
32
+ <uv-steps current="0">
33
+ <uv-steps-item title="已下单" desc="10:30"></uv-steps-item>
34
+ <uv-steps-item title="已出库" desc="10:35"></uv-steps-item>
35
+ <uv-steps-item title="运输中" desc="11:40"></uv-steps-item>
36
+ </uv-steps>
37
+ </template>
38
+ ```
39
+
40
+ ### 错误状态
41
+
42
+ 通过`uv-steps-item`的`error`属性设为`true`,当前步骤将会为“失败”的状态
43
+
44
+ ```vue
45
+ <template>
46
+ <uv-steps current="1">
47
+ <uv-steps-item title="已下单" desc="10:30"></uv-steps-item>
48
+ <uv-steps-item error title="仓库着火" desc="10:35"></uv-steps-item>
49
+ <uv-steps-item title="破产清算" desc="11:40"></uv-steps-item>
50
+ </uv-steps>
51
+ </template>
52
+ ```
53
+
54
+ ### 步骤条模式
55
+
56
+ 通过`dot`属性设置为`true`的话,将会以点状的形式展示步骤条样式
57
+
58
+ ```vue
59
+ <template>
60
+ <uv-steps current="1" dot>
61
+ <uv-steps-item title="已下单" desc="10:30"></uv-steps-item>
62
+ <uv-steps-item title="已出库" desc="10:35"></uv-steps-item>
63
+ <uv-steps-item title="运输中" desc="11:40"></uv-steps-item>
64
+ </uv-steps>
65
+ </template>
66
+ ```
67
+
68
+ ### 竖向模式
69
+
70
+ 通过`direction`属性设置为`column`,组件将会以竖向的形式展示步骤条内容
71
+
72
+ ```vue
73
+ <template>
74
+ <uv-steps current="1" direction="column">
75
+ <uv-steps-item title="已下单" desc="10:30"></uv-steps-item>
76
+ <uv-steps-item title="已出库" desc="10:35"></uv-steps-item>
77
+ <uv-steps-item title="运输中" desc="11:40"></uv-steps-item>
78
+ </uv-steps>
79
+ </template>
80
+ ```
81
+
82
+ ### 自定义图标
83
+
84
+ - 通过`activeIcon`属性可以设置激活状态的图标
85
+ - 通过`inactiveIcon`属性可以设置非激活状态的图标
86
+
87
+ ```vue
88
+ <template>
89
+ <uv-steps current="1" activeIcon="checkmark" inactiveIcon="arrow-right">
90
+ <uv-steps-item title="已下单" desc="10:30"></uv-steps-item>
91
+ <uv-steps-item title="已出库" desc="10:35"></uv-steps-item>
92
+ <uv-steps-item title="运输中" desc="11:40"></uv-steps-item>
93
+ </uv-steps>
94
+ </template>
95
+ ```
96
+
97
+ ### 通过插槽自定义图标
98
+
99
+ - 通过插槽`icon`自定义图标
100
+ - 通过`inactive-color`属性设置选中前的颜色,如果通过插槽`icon`自定义图标,该颜色设置的只有线条颜色
101
+ - 通过`active-color`属性设置选中后的颜色,如果通过插槽`icon`自定义图标,该颜色设置的只有线条颜色
102
+
103
+ ```vue
104
+ <template>
105
+ <uv-steps current="1" active-color="#3c9cff" inactive-color="#999">
106
+ <uv-steps-item title="已下单" desc="09:35">
107
+ <template v-slot:icon>
108
+ <uv-icon name="checkmark" color="#3c9cff"></uv-icon>
109
+ </template>
110
+ </uv-steps-item>
111
+ <uv-steps-item title="已出库" desc="10:35">
112
+ <template v-slot:icon>
113
+ <uv-icon name="checkmark" color="#3c9cff"></uv-icon>
114
+ </template>
115
+ </uv-steps-item>
116
+ <uv-steps-item title="运输中" desc="11:40"></uv-steps-item>
117
+ </uv-steps>
118
+ </template>
119
+ ```
120
+
121
+ ### 通过插槽自定义内容
122
+
123
+ - 通过插槽`title`自定义标题内容
124
+ - 通过插槽`desc`自定义描述内容
125
+
126
+ ```vue
127
+ <template>
128
+ <uv-steps current="1">
129
+ <uv-steps-item>
130
+ <template v-slot:title>
131
+ <text>已下单</text>
132
+ </template>
133
+ <template v-slot:desc>
134
+ <text>00:00</text>
135
+ </template>
136
+ </uv-steps-item>
137
+ <uv-steps-item title="已出库" desc="10:35"></uv-steps-item>
138
+ <uv-steps-item title="运输中" desc="11:40"></uv-steps-item>
139
+ </uv-steps>
140
+ </template>
141
+ ```
142
+
143
+ ### 完整示例
144
+
145
+ ::: tip 完整示例下载地址
146
+
147
+ [https://ext.dcloud.net.cn/plugin?name=uv-ui](https://ext.dcloud.net.cn/plugin?name=uv-ui)
148
+
149
+ :::
150
+
151
+ ### API
152
+ ---
153
+
154
+ ### Steps Props
155
+
156
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 |
157
+ |:- |:- |:- |:- |:- |
158
+ | direction | `row` - 横向,`column` - 竖向 | String | row | row &#124; column |
159
+ | current | 设置当前处于第几步 | Number &#124; String | 0 | - |
160
+ | activeColor | 激活状态颜色 | String | #3c9cff | - |
161
+ | inactiveColor | 未激活状态颜色 | String | #969799 | - |
162
+ | activeIcon | 激活状态的图标 | String | - | - |
163
+ | inactiveIcon | 未激活状态图标 | String | - | - |
164
+ | dot | 是否显示点类型 | Boolean | false | true &#124; false |
165
+ | customStyle | 自定义外部样式 | Object | - |
166
+
167
+
168
+ ### StepsItem Props
169
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 |
170
+ |:- |:- |:- |:- |:- |
171
+ | title | 标题文字 | String | - | - |
172
+ | desc | 描述文本 | String | - | - |
173
+ | iconSize | 图标大小,需要`uv-steps`设置`activeIcon`或`inactiveIcon`。单位`px(rpx)` | String &#124; Number | 17 | - |
174
+ | error | 当前步骤是否处于失败状态 | Boolean | false | true &#124; false |
175
+ | customStyle | 自定义外部样式,可以利用该属性设置`padding`调整间距等场景 | Object | - |
176
+
177
+ ### StepsItem Slots
178
+
179
+ | 名称 | 说明 |
180
+ |:- |:- |
181
+ | icon | 自定义图标 |
182
+ | title | 自定义标题文字 |
183
+ | desc | 自定义描述文字 |
184
+
185
+ <style>
186
+ h3[id=stepsitem-slots] + table thead tr th:nth-child(2){
187
+ width: 70%;
188
+ }
189
+ </style>
@@ -0,0 +1,76 @@
1
+ ## Sticky 吸顶 <to-api/>
2
+
3
+ <demo-model url="/pages/componentsD/sticky/sticky"></demo-model>
4
+
5
+ ::: tip ✈
6
+
7
+ **组件名:uv-sticky**
8
+
9
+ [点击下载&安装](https://ext.dcloud.net.cn/plugin?name=uv-sticky)
10
+
11
+ :::
12
+
13
+ 该组件与CSS中`position: sticky`属性实现的效果一致,当组件达到预设的到顶部距离时,
14
+ 就会固定在指定位置,组件位置大于预设的顶部距离时,会重新按照正常的布局排列。
15
+
16
+ ### 平台兼容性
17
+
18
+ |App(vue)|App(nvue)|H5|小程序|VUE2|VUE3|
19
+ |:-:|:-:|:-:|:-:|:-:|:-:|
20
+ |√|√|√|√|√|√|
21
+
22
+ :::tip 说明
23
+ 本组件内部通过多种手段判断当前运行环境是否支持`css sticky`,在`H5`,`APP-VUE`,`NVUE`,`MP-WEIIXN`,`安卓`
24
+ 等环境可以进行准确判断,如果支持则使用`CSS`方案,否则使用降级的`JS`方案。
25
+ :::
26
+
27
+ ### 基本使用
28
+
29
+ 由于`css sticky`的特殊性,建议您将此组件放置在页面外层元素中,否则可能会导致`sticky`失效,以下为[MDN对sticky的解释](https://developer.mozilla.org/zh-CN/docs/Web/CSS/position):
30
+ - 元素根据正常文档流进行定位,然后相对它的最近滚动祖先(nearest scrolling ancestor)和 containing block (最近块级祖先 nearest block-level ancestor),包括table-related元素,基于top, right, bottom, 和 left的值进行偏移。偏移值不会影响任何其他元素的位置。
31
+
32
+ ```vue
33
+ <template>
34
+ <view class="container">
35
+ <!-- 建议放在外层 -->
36
+ <uv-sticky>......</uv-sticky>
37
+ <view class="container__inner">
38
+ <!-- 不建议放在层层嵌套的view中,除非您清楚知道自己为什么需要这么做 -->
39
+ <uv-sticky>......</uv-sticky>
40
+ </view>
41
+ </view>
42
+ </template>
43
+ ```
44
+
45
+ ### 吸顶距离
46
+
47
+ 通过`offset-top`参数设置组件在吸顶时与顶部的距离
48
+
49
+ ```vue
50
+ <uv-sticky offset-top="20">
51
+ <text>塞下秋来风景异,衡阳雁去无留意</text>
52
+ </uv-sticky>
53
+ ```
54
+
55
+ ### 完整示例
56
+
57
+ ::: tip 完整示例下载地址
58
+
59
+ [https://ext.dcloud.net.cn/plugin?name=uv-ui](https://ext.dcloud.net.cn/plugin?name=uv-ui)
60
+
61
+ :::
62
+
63
+ ### API
64
+ ---
65
+
66
+ ### Sticky Props
67
+
68
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 |
69
+ |:- |:- |:- |:- |:- |
70
+ | offsetTop | 吸顶时与顶部的距离,单位`px(rpx)` | String &#124; Number | 0 | - |
71
+ | customNavHeight | 导航栏高度,自定义导航栏时,需要传入此值 | String &#124; Number | 0 | - |
72
+ | disabled | 是否禁用吸顶功能 | Boolean | false | true &#124; false |
73
+ | bgColor | 组件背景颜色 | String | #ffffff | - |
74
+ | zIndex | 吸顶时的`z-index`值,`NVUE`无效 | String &#124; Number | - | - |
75
+ | index | 自定义标识,用于区分是哪一个组件 | String &#124; Number | - | - |
76
+
@@ -0,0 +1,183 @@
1
+ ## Subsection 分段器 <to-api/>
2
+
3
+ <demo-model url="/pages/componentsD/subsection/subsection"></demo-model>
4
+
5
+ ::: tip ✈
6
+
7
+ **组件名:uv-subsection**
8
+
9
+ [点击下载&安装](https://ext.dcloud.net.cn/plugin?name=uv-subsection)
10
+
11
+ :::
12
+
13
+ 该分段器一般用于用户从几个选项中选择某一个的场景
14
+
15
+ ### 平台兼容性
16
+
17
+ |App(vue)|App(nvue)|H5|小程序|VUE2|VUE3|
18
+ |:-:|:-:|:-:|:-:|:-:|:-:|
19
+ |√|√|√|√|√|√|
20
+
21
+ ::: warning 注意
22
+
23
+ 如果在弹窗等场景使用显示异常,需要使用v-if进行控制,详情请参考[为什么部分组件在弹出层中显示异常或功能异常](https://www.uvui.cn/components/problem.html#五、为什么部分组件在弹出层中显示异常或功能异常)
24
+
25
+ :::
26
+
27
+ ### 基本使用
28
+
29
+ - 通过`list`数组参数传递分段的选项,数组元素可为字符串,或者通过`keyName`参数传入对象(默认为`name`)
30
+ - 通过`current`属性指定初始化时激活的选项
31
+
32
+ ```vue
33
+ <template>
34
+ <uv-subsection :list="list" :current="current" @change="change"></uv-subsection>
35
+ </template>
36
+ <script setup>
37
+ import { ref } from 'vue';
38
+
39
+ const list = ref(['未付款', '待评价', '已付款']);
40
+ const current = ref(1);
41
+ function change(index) {
42
+ current.value = index;
43
+ }
44
+
45
+ </script>
46
+ ```
47
+
48
+ ### 模式选择
49
+
50
+ 通过`mode`属性设置分段器的模式
51
+ - 值为`button`时为按钮类型,默认该值
52
+ - 值为`subsection`时为分段器形式
53
+
54
+ ```vue
55
+ <template>
56
+ <uv-subsection :list="list" mode="subsection" :current="current" @change="change"></uv-subsection>
57
+ </template>
58
+ <script setup>
59
+ import { ref } from 'vue';
60
+
61
+ const list = ref(['未付款', '待评价', '已付款']);
62
+ const current = ref(1);
63
+ function change(index) {
64
+ current.value = index;
65
+ }
66
+
67
+ </script>
68
+ ```
69
+
70
+ ### 颜色配置
71
+
72
+ - 通过`activeColor`配置激活选项的文字颜色
73
+ - 通过`inactiveColor`配置未激活选项的文字颜色
74
+ - 通过`bgColor`配置背景颜色,`mode="button"`时有效(默认`#eeeeef` )
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
+ <script setup>
89
+ import { ref } from 'vue';
90
+
91
+ const list = ref(['未付款', '待评价', '已付款']);
92
+ const current = ref(1);
93
+ function change(index) {
94
+ current.value = index;
95
+ }
96
+
97
+ </script>
98
+ ```
99
+
100
+ ### 自定义样式
101
+
102
+ 通过`custom-style`和`custom-item-style`属性可以自定义一些样式,比如设置圆角等,示例如下:
103
+
104
+ ```vue
105
+ <template>
106
+ <uv-subsection
107
+ :list="list"
108
+ :current="current"
109
+ custom-style="height: 60rpx;border-radius: 30rpx;"
110
+ custom-item-style="border-radius: 30rpx;"
111
+ @change="change"></uv-subsection>
112
+ </template>
113
+ <script setup>
114
+ import { ref } from 'vue';
115
+
116
+ const list = ref(['未付款', '待评价', '已付款']);
117
+ const current = ref(1);
118
+ function change(index) {
119
+ current.value = index;
120
+ }
121
+
122
+ </script>
123
+ ```
124
+
125
+ ### 注意事项
126
+
127
+ 如果想通过一个变量绑定`current`值,需要在`change`事件回调中修改此值,否则可能会由于`props`的限制,前后两次设置`current`为相同的值,
128
+ 而导致无法通过修改`current`值触发分段器的变化。
129
+
130
+ ```vue
131
+ <template>
132
+ <uv-subsection :list="list" :current="current" @change="change"></uv-subsection>
133
+ </template>
134
+ <script setup>
135
+ import { ref } from 'vue';
136
+
137
+ const list = ref(['未付款', '待评价', '已付款']);
138
+ const current = ref(0);
139
+ function change(index) {
140
+ current.value = index;
141
+ }
142
+
143
+ </script>
144
+ ```
145
+
146
+ ### 完整示例
147
+
148
+ ::: tip 完整示例下载地址
149
+
150
+ [https://ext.dcloud.net.cn/plugin?name=uv-ui](https://ext.dcloud.net.cn/plugin?name=uv-ui)
151
+
152
+ :::
153
+
154
+ ### API
155
+ ---
156
+
157
+ ### Subsection Props
158
+
159
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 |
160
+ |:- |:- |:- |:- |:- |
161
+ | list | 选项的数组,形式见上方"基本使用" | Array | - | - |
162
+ | keyName | 从`list`元素对象中读取的键名 | String | name | - |
163
+ | current | 初始化时默认选中的选项索引值 | String &#124; Number | 0 | - |
164
+ | activeColor | 激活时的颜色 | String | #3c9cff | - |
165
+ | inactiveColor| 未激活时的颜色 | String | #303133 | - |
166
+ | mode | 模式选择,见上方"模式选择"说明 | String | button | button &#124; subsection|
167
+ | fontSize | 字体大小,单位`px(rpx)` | String &#124; Number | 12 | - |
168
+ | bold | 激活选项的字体是否加粗 | Boolean | true | true &#124; false |
169
+ | bgColor | 组件背景颜色,`mode`为`button`时有效 | String | #eeeeef | - |
170
+ | customStyle | 自定义外部样式 | String &#124; Object | - | - |
171
+ | customItemStyle | 自定义bar样式 | String &#124; Object | - | - |
172
+
173
+ ### Popup Methods
174
+
175
+ | 方法名 | 说明 | 参数 |
176
+ |:- |:- |:- |
177
+ | init | 初始化 | 如果是在弹窗等场景使用,可能造成打开弹窗之前因为计算不准确导致错乱,可以在打开时候通过该方法进行初始化即可正常 |
178
+
179
+ ### Subsection Events
180
+
181
+ | 事件名| 说明 | 回调参数 |
182
+ | :- | :- | :- |
183
+ | change| 分段器选项发生改变时触发 | index:选项的index索引值,从0开始 |