@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.
- package/CHANGELOG.md +8 -0
- package/LICENSE +21 -21
- package/README.md +95 -141
- package/components/uv-overlay/props.js +29 -24
- package/components/uv-overlay/uv-overlay.vue +87 -85
- package/docs/api/configs/color.md +52 -0
- package/docs/api/index.md +77 -0
- package/docs/api/mixins/mpShare.md +95 -0
- package/docs/api/request/apiManage.md +88 -0
- package/docs/api/request/http.md +451 -0
- package/docs/api/utils/colorSwitch.md +78 -0
- package/docs/api/utils/debounce.md +104 -0
- package/docs/api/utils/fastUse.md +246 -0
- package/docs/api/utils/getRect.md +238 -0
- package/docs/api/utils/guid.md +41 -0
- package/docs/api/utils/index.md +55 -0
- package/docs/api/utils/intro.md +25 -0
- package/docs/api/utils/object.md +171 -0
- package/docs/api/utils/queryParams.md +68 -0
- package/docs/api/utils/random.md +23 -0
- package/docs/api/utils/randomArray.md +28 -0
- package/docs/api/utils/route.md +121 -0
- package/docs/api/utils/test.md +237 -0
- package/docs/api/utils/time.md +81 -0
- package/docs/api/utils/trim.md +24 -0
- package/docs/components/actionSheet.md +236 -0
- package/docs/components/addQQGroup.md +5 -0
- package/docs/components/album.md +91 -0
- package/docs/components/alert.md +83 -0
- package/docs/components/avatar.md +152 -0
- package/docs/components/backTop.md +181 -0
- package/docs/components/badge.md +117 -0
- package/docs/components/button.md +196 -0
- package/docs/components/calendar.md +398 -0
- package/docs/components/calendars.md +294 -0
- package/docs/components/cell.md +185 -0
- package/docs/components/checkbox.md +281 -0
- package/docs/components/circleProgress.md +5 -0
- package/docs/components/code.md +162 -0
- package/docs/components/codeInput.md +175 -0
- package/docs/components/collapse.md +250 -0
- package/docs/components/color.md +324 -0
- package/docs/components/common.md +126 -0
- package/docs/components/countDown.md +166 -0
- package/docs/components/countTo.md +140 -0
- package/docs/components/datetimePicker.md +283 -0
- package/docs/components/diff1.x.md +190 -0
- package/docs/components/divider.md +88 -0
- package/docs/components/downloadSetting.md +54 -0
- package/docs/components/dropDown.md +375 -0
- package/docs/components/empty.md +99 -0
- package/docs/components/feature.md +261 -0
- package/docs/components/form.md +736 -0
- package/docs/components/gap.md +49 -0
- package/docs/components/grid.md +225 -0
- package/docs/components/icon.md +101 -0
- package/docs/components/image.md +182 -0
- package/docs/components/index.md +110 -0
- package/docs/components/indexList.md +133 -0
- package/docs/components/input.md +250 -0
- package/docs/components/install.md +59 -0
- package/docs/components/intro.md +32 -0
- package/docs/components/keyboard.md +226 -0
- package/docs/components/layout.md +310 -0
- package/docs/components/line.md +85 -0
- package/docs/components/lineProgress.md +141 -0
- package/docs/components/link.md +89 -0
- package/docs/components/list.md +223 -0
- package/docs/components/loadMore.md +140 -0
- package/docs/components/loadingIcon.md +144 -0
- package/docs/components/loadingPage.md +92 -0
- package/docs/components/modal.md +230 -0
- package/docs/components/more.md +13 -0
- package/docs/components/navbar.md +192 -0
- package/docs/components/noNetwork.md +116 -0
- package/docs/components/noticeBar.md +131 -0
- package/docs/components/notify.md +204 -0
- package/docs/components/npmSetting.md +64 -0
- package/docs/components/numberBox.md +257 -0
- package/docs/components/nvue.md +170 -0
- package/docs/components/overlay.md +117 -0
- package/docs/components/parse.md +204 -0
- package/docs/components/pickColor.md +112 -0
- package/docs/components/picker.md +357 -0
- package/docs/components/popup.md +221 -0
- package/docs/components/problem.md +300 -0
- package/docs/components/qrcode.md +169 -0
- package/docs/components/quickstart.md +33 -0
- package/docs/components/radio.md +256 -0
- package/docs/components/rate.md +128 -0
- package/docs/components/read.md +163 -0
- package/docs/components/readMore.md +227 -0
- package/docs/components/resource.md +17 -0
- package/docs/components/scrollList.md +218 -0
- package/docs/components/search.md +160 -0
- package/docs/components/setting.md +111 -0
- package/docs/components/settingDesc.md +66 -0
- package/docs/components/skeleton.md +105 -0
- package/docs/components/skeletons.md +323 -0
- package/docs/components/slider.md +157 -0
- package/docs/components/steps.md +189 -0
- package/docs/components/sticky.md +76 -0
- package/docs/components/subsection.md +183 -0
- package/docs/components/swipeAction.md +279 -0
- package/docs/components/swiper.md +352 -0
- package/docs/components/switch.md +216 -0
- package/docs/components/tabbar.md +263 -0
- package/docs/components/table.md +5 -0
- package/docs/components/tabs.md +364 -0
- package/docs/components/tag.md +227 -0
- package/docs/components/testPic.md +20 -0
- package/docs/components/text.md +157 -0
- package/docs/components/textarea.md +121 -0
- package/docs/components/toast.md +124 -0
- package/docs/components/tooltip.md +98 -0
- package/docs/components/transition.md +404 -0
- package/docs/components/upload.md +253 -0
- package/docs/components/vtabs.md +332 -0
- package/docs/components/vueUse.md +45 -0
- package/docs/components/vuexDetail.md +103 -0
- package/docs/components/waterfall.md +651 -0
- package/docs/faq/index.md +53 -0
- package/docs/guide/codeHint.md +44 -0
- package/docs/guide/customIcon.md +168 -0
- package/docs/guide/demo.md +92 -0
- package/docs/guide/design.md +56 -0
- package/docs/guide/globalVariable.md +239 -0
- package/docs/guide/i18n.md +194 -0
- package/docs/guide/index.md +28 -0
- package/docs/guide/note.md +74 -0
- package/docs/guide/safeAreaInset.md +64 -0
- package/docs/guide/theme.md +67 -0
- package/docs/index.md +88 -0
- package/libs/config/config.js +0 -10
- package/libs/css/color.scss +15 -14
- package/package.json +7 -2
- package/theme.scss +2 -1
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
## BackTop 返回顶部 <to-api/>
|
|
2
|
+
|
|
3
|
+
<demo-model url="/pages/componentsD/backtop/backtop"></demo-model>
|
|
4
|
+
|
|
5
|
+
::: tip ✈
|
|
6
|
+
|
|
7
|
+
**组件名:uv-back-top**
|
|
8
|
+
|
|
9
|
+
[点击下载&安装](https://ext.dcloud.net.cn/plugin?name=uv-back-top)
|
|
10
|
+
|
|
11
|
+
:::
|
|
12
|
+
|
|
13
|
+
该组件一个用于长页面,滑动一定距离后,出现返回顶部按钮,点击按钮快速返回顶部的场景。
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### 平台兼容性
|
|
17
|
+
|
|
18
|
+
|App(vue)|App(nvue)|H5|小程序|VUE2|VUE3|
|
|
19
|
+
|:-:|:-:|:-:|:-:|:-:|:-:|
|
|
20
|
+
|√|√|√|√|√|√|
|
|
21
|
+
|
|
22
|
+
### 基本使用
|
|
23
|
+
|
|
24
|
+
由于返回顶部需要实时监听滚动条的位置,从而判断返回的按钮该出现还是隐藏,由于组件无法得知页面的滚动条信息,只能在**页面**的`onPageScroll`生命周期中获得滚动条的位置。故需要在页面监听`onPageScroll`生命周期,实时获得滚动条的位置,通过Props传递给组件。
|
|
25
|
+
|
|
26
|
+
::: warning 注意
|
|
27
|
+
1. `nvue` 页面需要给页面最外层元素设置 `ref='uv-back-top'`
|
|
28
|
+
2. `onPageScroll` 周期函数中获取值也有些区别,`nvue`中为`e.detail.scrollTop`,`vue`中为`e.scrollTop`
|
|
29
|
+
:::
|
|
30
|
+
|
|
31
|
+
```vue
|
|
32
|
+
<template>
|
|
33
|
+
<view class="wrap" ref="backTop">
|
|
34
|
+
<text>滑动页面,返回顶部按钮将出现在右下角</text>
|
|
35
|
+
<uv-back-top :scroll-top="scrollTop"></uv-back-top>
|
|
36
|
+
</view>
|
|
37
|
+
</template>
|
|
38
|
+
<script setup>
|
|
39
|
+
import { ref } from 'vue';
|
|
40
|
+
|
|
41
|
+
const backTop = ref(null);
|
|
42
|
+
const scrollTop = ref(0);
|
|
43
|
+
|
|
44
|
+
</script>
|
|
45
|
+
<style lang="scss" scoped>
|
|
46
|
+
.wrap {
|
|
47
|
+
height: 2000px;
|
|
48
|
+
}
|
|
49
|
+
</style>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### 改变返回顶部按钮的出现时机
|
|
54
|
+
|
|
55
|
+
通过`top`属性设置页面滚动多少距离时,出现返回顶部的按钮
|
|
56
|
+
|
|
57
|
+
```vue
|
|
58
|
+
<template>
|
|
59
|
+
<view class="wrap" style="height: 2000px;" ref="backTop" top="600">
|
|
60
|
+
<text>滑动页面,返回顶部按钮将出现在右下角</text>
|
|
61
|
+
<uv-back-top :scroll-top="scrollTop"></uv-back-top>
|
|
62
|
+
</view>
|
|
63
|
+
</template>
|
|
64
|
+
<script setup>
|
|
65
|
+
import { ref } from 'vue';
|
|
66
|
+
|
|
67
|
+
const backTop = ref(null);
|
|
68
|
+
const scrollTop = ref(0);
|
|
69
|
+
|
|
70
|
+
</script>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 自定义返回顶部的图标和提示
|
|
74
|
+
|
|
75
|
+
- 通过`icon`属性设置返回顶部按钮的图标,可以是`uv-ui`内置的图标,或者图片路径
|
|
76
|
+
- 通过`text`属性设置返回顶部按钮的文字提示信息,如果需要修改文字的颜色和大小,可以通过`customStyle`参数
|
|
77
|
+
|
|
78
|
+
```vue
|
|
79
|
+
<template>
|
|
80
|
+
<view class="wrap" style="height: 2000px;" ref="backTop" top="600">
|
|
81
|
+
<text>滑动页面,返回顶部按钮将出现在右下角</text>
|
|
82
|
+
<uv-back-top :scroll-top="scrollTop" icon="arrow-up" text="返回"></uv-back-top>
|
|
83
|
+
</view>
|
|
84
|
+
</template>
|
|
85
|
+
<script setup>
|
|
86
|
+
import { ref } from 'vue';
|
|
87
|
+
|
|
88
|
+
const backTop = ref(null);
|
|
89
|
+
const scrollTop = ref(0);
|
|
90
|
+
|
|
91
|
+
</script>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 其他自定义样式
|
|
95
|
+
|
|
96
|
+
- 通过`iconStyle`属性自定义图标的样式,比如颜色,大小等
|
|
97
|
+
- 通过`customStyle`属性设置返回按钮的背景颜色,大小等
|
|
98
|
+
- 通过`mode`属性设置按钮的形状,`circle`为圆形,`square`为方形
|
|
99
|
+
|
|
100
|
+
::: warning 注意
|
|
101
|
+
如果通过`icon`参数传入图片路径的话,需要通过`iconStyle`参数设置图片的`width`和`height`属性
|
|
102
|
+
:::
|
|
103
|
+
|
|
104
|
+
```vue
|
|
105
|
+
<template>
|
|
106
|
+
<view class="wrap" style="height: 2000px;" ref="backTop" top="600">
|
|
107
|
+
<text>滑动页面,返回顶部按钮将出现在右下角</text>
|
|
108
|
+
<uv-back-top
|
|
109
|
+
:scroll-top="scrollTop"
|
|
110
|
+
icon="arrow-up"
|
|
111
|
+
text="返回"
|
|
112
|
+
:mode="mode"
|
|
113
|
+
:iconStyle="iconStyle"
|
|
114
|
+
:customStyle="customStyle"
|
|
115
|
+
></uv-back-top>
|
|
116
|
+
</view>
|
|
117
|
+
</template>
|
|
118
|
+
<script setup>
|
|
119
|
+
import { ref } from 'vue';
|
|
120
|
+
|
|
121
|
+
const backTop = ref(null);
|
|
122
|
+
const scrollTop = ref(0);
|
|
123
|
+
const mode = ref('square');
|
|
124
|
+
const customStyle = ref({
|
|
125
|
+
fontSize: '24rpx',
|
|
126
|
+
color: '#2979ff'
|
|
127
|
+
});
|
|
128
|
+
const iconStyle = ref({
|
|
129
|
+
fontSize: '32rpx',
|
|
130
|
+
color: '#2979ff'
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
</script>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### 完整示例
|
|
137
|
+
|
|
138
|
+
::: tip 完整示例下载地址
|
|
139
|
+
|
|
140
|
+
[https://ext.dcloud.net.cn/plugin?name=uv-ui](https://ext.dcloud.net.cn/plugin?name=uv-ui)
|
|
141
|
+
|
|
142
|
+
:::
|
|
143
|
+
|
|
144
|
+
### API
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
### BackTop Props
|
|
148
|
+
|
|
149
|
+
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
|
150
|
+
|:- |:- |:- |:- |:- |
|
|
151
|
+
| mode | 按钮形状,`circle`为圆形,`square`为方形 | String | circle | circle | square |
|
|
152
|
+
| icon | `uv-ui`内置图标名称,或图片路径 | String | arrow-upward | - |
|
|
153
|
+
| text | 返回顶部按钮的提示文字 | String | - | - |
|
|
154
|
+
| duration | 返回顶部过程中的过渡时间,单位`ms` | String | Number | 100 | - |
|
|
155
|
+
| scrollTop | 页面的滚动距离,通过`onPageScroll`生命周期获取| String | Number | 0 | - |
|
|
156
|
+
| top | 滚动条滑动多少距离时显示,单位`px(rpx)` | String | Number | 400 | - |
|
|
157
|
+
| bottom | 返回按钮位置到屏幕底部的距离,单位`px(rpx)` | String | Number | 100 | - |
|
|
158
|
+
| right | 返回按钮位置到屏幕右边的距离,单位`px(rpx)` | String | Number | 20 | - |
|
|
159
|
+
| z-index | 返回顶部按钮的层级 | String | Number | 9 | - |
|
|
160
|
+
| iconStyle | 图标的样式,对象形式 | Object | - | - |
|
|
161
|
+
| customStyle | 按钮外层的自定义样式 | Object | - | - |
|
|
162
|
+
|
|
163
|
+
### BackTop Methods
|
|
164
|
+
| 方法名 | 说明 |
|
|
165
|
+
| :-| :- |
|
|
166
|
+
| backToTop | 自定义内容的时,可以调用此方法返回顶部 |
|
|
167
|
+
|
|
168
|
+
### BackTop Slots
|
|
169
|
+
|
|
170
|
+
|名称 |说明 |
|
|
171
|
+
|:- |:- |
|
|
172
|
+
| default | 自定义返回按钮的所有内容 |
|
|
173
|
+
|
|
174
|
+
<style scoped>
|
|
175
|
+
h3[id=backtop-slots] + table thead tr th:nth-child(2){
|
|
176
|
+
width: 70%;
|
|
177
|
+
}
|
|
178
|
+
h3[id=backtop-methods] + table thead tr th:nth-child(2){
|
|
179
|
+
width: 70%;
|
|
180
|
+
}
|
|
181
|
+
</style>
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
## Badge 徽标数(数字角标) <to-api/>
|
|
2
|
+
|
|
3
|
+
<demo-model url="/pages/componentsD/badge/badge"></demo-model>
|
|
4
|
+
|
|
5
|
+
::: tip ✈
|
|
6
|
+
|
|
7
|
+
**组件名:uv-badge**
|
|
8
|
+
|
|
9
|
+
[点击下载&安装](https://ext.dcloud.net.cn/plugin?name=uv-badge)
|
|
10
|
+
|
|
11
|
+
:::
|
|
12
|
+
|
|
13
|
+
该组件一般用于显示未读的消息或数量提示,可以配合`uv-tabs`、`uv-vtabs`等组件使用。有圆点和圆包含文字两种形式,默认`error`背景色。
|
|
14
|
+
|
|
15
|
+
### 平台兼容性
|
|
16
|
+
|
|
17
|
+
|App(vue)|App(nvue)|H5|小程序|VUE2|VUE3|
|
|
18
|
+
|:-:|:-:|:-:|:-:|:-:|:-:|
|
|
19
|
+
|√|√|√|√|√|√|
|
|
20
|
+
|
|
21
|
+
### 基本使用
|
|
22
|
+
|
|
23
|
+
- 通过`value`参数定义徽标内容
|
|
24
|
+
- 通过`type`设置主题。重申一次,uv-ui中,所有组件的`type`参数都只有5个固定的可选值,分别是`primary`(蓝色-主色),`warning`(黄色-警告),
|
|
25
|
+
`error`(红色-错误),`success`(绿色-成功),`info`(灰色-信息)
|
|
26
|
+
- 通过`max`参数控制最大值,超过最大值会显示 '{max}+'
|
|
27
|
+
|
|
28
|
+
```vue
|
|
29
|
+
<template>
|
|
30
|
+
<view style="padding: 20px;">
|
|
31
|
+
<view class="box">
|
|
32
|
+
<uv-badge type="error" max="99" :value="100"></uv-badge>
|
|
33
|
+
</view>
|
|
34
|
+
</view>
|
|
35
|
+
</template>
|
|
36
|
+
<style lang="scss" scoped>
|
|
37
|
+
.box {
|
|
38
|
+
width: 50px;
|
|
39
|
+
height: 50px;
|
|
40
|
+
background-color: #909193;
|
|
41
|
+
}
|
|
42
|
+
</style>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 设置徽标的类型为一个圆点
|
|
46
|
+
|
|
47
|
+
通过`:isDot="true"`属性设置,该形式组件没有内容,只显示一个圆点
|
|
48
|
+
|
|
49
|
+
```vue
|
|
50
|
+
<uv-badge :isDot="true" type="success"></uv-badge>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 设置数字的显示方式 `overflow` `ellipsis` `limit`
|
|
54
|
+
|
|
55
|
+
- `overflow`会根据max字段判断,超出显示`${max}+`
|
|
56
|
+
- `ellipsis`会根据max判断,超出直接显示`...`
|
|
57
|
+
- `limit`会依据1000作为判断条件,超出1000,显示`${value/1000}K`,比如2.2k、3.34w,最多保留2位小数
|
|
58
|
+
|
|
59
|
+
```vue
|
|
60
|
+
<template>
|
|
61
|
+
<view style="padding: 20px;">
|
|
62
|
+
<view class="box">
|
|
63
|
+
<uv-badge numberType="overflow" type="error" max="99" :value="100"></uv-badge>
|
|
64
|
+
</view>
|
|
65
|
+
<view class="box">
|
|
66
|
+
<uv-badge numberType="ellipsis" type="error" max="99" :value="10000"></uv-badge>
|
|
67
|
+
</view>
|
|
68
|
+
<view class="box">
|
|
69
|
+
<uv-badge numberType="limit" type="error" max="99" :value="100"></uv-badge>
|
|
70
|
+
</view>
|
|
71
|
+
</view>
|
|
72
|
+
</template>
|
|
73
|
+
<style lang="scss" scoped>
|
|
74
|
+
.box {
|
|
75
|
+
width: 50px;
|
|
76
|
+
height: 50px;
|
|
77
|
+
background-color: #909193;
|
|
78
|
+
}
|
|
79
|
+
</style>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 完整示例
|
|
83
|
+
|
|
84
|
+
::: tip 完整示例下载地址
|
|
85
|
+
|
|
86
|
+
[https://ext.dcloud.net.cn/plugin?name=uv-ui](https://ext.dcloud.net.cn/plugin?name=uv-ui)
|
|
87
|
+
|
|
88
|
+
:::
|
|
89
|
+
|
|
90
|
+
### API
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### Badge Props
|
|
94
|
+
|
|
95
|
+
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
|
96
|
+
|:- |:- |:- |:- |:- |
|
|
97
|
+
| value | 展示的数字,大于 `max` 时显示为 `${max}+`;为`0`且`show-zero`为`false`时隐藏 | String | Number | - | - |
|
|
98
|
+
| isDot | 不展示数字,只有一个小点 | Boolean | false | true | false |
|
|
99
|
+
| show | 组件是否显示 | Boolean | true | true | false |
|
|
100
|
+
| max | 最大值,超过最大值会显示 '{max}+' | String | Number | 99 | - |
|
|
101
|
+
| type | 主题类型 | String | error | error | warning | success | primary | info|
|
|
102
|
+
| showZero | 当数值为 0 时,是否展示 Badge | Boolean | false | true | false |
|
|
103
|
+
| bgColor | 背景颜色,优先级比`type`高。如设置该属性,`type`参数就会失效 | String | - | - |
|
|
104
|
+
| color | 字体颜色 | String | #ffffff | - |
|
|
105
|
+
| shape | 徽标形状,circle-四角均为圆角,horn-左下角为直角 | String | circle | circle | horn |
|
|
106
|
+
| numberType| 置数字的显示方式,详细见上方文档 | String | overflow | overflow | ellipsis | limit |
|
|
107
|
+
| inverted | 是否反转背景和字体颜色 | Boolean | false | true | false |
|
|
108
|
+
| absolute | 组件是否绝对定位,为`true`时,`offset`参数才有效 | Boolean | false | true | false |
|
|
109
|
+
| offset | 设置badge的位置偏移,格式为 [x, y],也即设置的为`top`和`right`的值,`absolute`为`true`时有效 | Array | - | - |
|
|
110
|
+
| customStyle | 自定义外部样式 | Object | - | - |
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
<style scoped>
|
|
114
|
+
h3[id=badge-props] + table thead tr th:nth-child(2){
|
|
115
|
+
width: 40%;
|
|
116
|
+
}
|
|
117
|
+
</style>
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
## Button 按钮 <to-api/>
|
|
2
|
+
|
|
3
|
+
<demo-model url="/pages/componentsA/button/button"></demo-model>
|
|
4
|
+
|
|
5
|
+
::: tip ✈
|
|
6
|
+
|
|
7
|
+
**组件名:uv-button**
|
|
8
|
+
|
|
9
|
+
[点击下载&安装](https://ext.dcloud.net.cn/plugin?name=uv-button)
|
|
10
|
+
|
|
11
|
+
:::
|
|
12
|
+
|
|
13
|
+
该组件内部实现以uni-app`button`组件为基础,进行二次封装,主要区别在于:
|
|
14
|
+
- 按钮`type`值有更多的主题颜色
|
|
15
|
+
- 按钮`size`值有更多的尺寸可选
|
|
16
|
+
|
|
17
|
+
### 平台兼容性
|
|
18
|
+
|
|
19
|
+
|App(vue)|App(nvue)|H5|小程序|VUE2|VUE3|
|
|
20
|
+
|:-:|:-:|:-:|:-:|:-:|:-:|
|
|
21
|
+
|√|√|√|√|√|√|
|
|
22
|
+
|
|
23
|
+
:::warning 注意事项
|
|
24
|
+
|
|
25
|
+
> 为了避免错误使用,给大家带来不好的开发体验,请在使用组件前仔细阅读下面的注意事项,可以帮你避免一些错误。
|
|
26
|
+
1. 本组件在 `button` 组件基础上扩展更多实用功能,部分属性与官方组件属性完全一致,由于 `button` 组件比较特殊,它有一些其他小程序平台的特定能力,更详细说明请参uni-app方文档:[uni-app之button组件](https://uniapp.dcloud.io/component/button)。
|
|
27
|
+
2. 由于微信小程序的限制,在微信小程序中设置了 `form-type` 的 `uv-button` 无法触发 `form` 组件的 `@submit` 事件(H5和APP正常),详见微信小程序文档[Bug & Tip部分](https://developers.weixin.qq.com/miniprogram/dev/component/button.html)。
|
|
28
|
+
3. 如果需要给 `uv-button` 设置宽度,建议给按钮外面套一个view元素,控制view的宽度,或者使用 `customStyle` 属性进行设置。
|
|
29
|
+
:::
|
|
30
|
+
|
|
31
|
+
### 基本使用
|
|
32
|
+
文字内容通过`text`传入
|
|
33
|
+
|
|
34
|
+
```vue
|
|
35
|
+
<uv-button text="月落"></uv-button>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 设置按钮的多种形态
|
|
39
|
+
|
|
40
|
+
- `type`值可选的有`default`(默认)、`primary`、`success`、`info`、`warning`、`error`
|
|
41
|
+
- 通过`plain`值设置是否镂空
|
|
42
|
+
- 通过`hairline`值设置是否细边
|
|
43
|
+
- 通过`disabled`值设置是否禁用
|
|
44
|
+
- 通过`loading`值设置是否开启加载图标,`loadingText`设置加载中文字
|
|
45
|
+
- 通过`icon`值设置是否显示图标
|
|
46
|
+
- 通过`shape`值设置按钮形状,circle为圆角
|
|
47
|
+
- 通过`color`值设置按钮渐变颜色
|
|
48
|
+
- 通过`size`值设置按钮的大小
|
|
49
|
+
|
|
50
|
+
```vue
|
|
51
|
+
<template>
|
|
52
|
+
<view style="padding: 20px;">
|
|
53
|
+
<uv-button type="primary" text="确定"></uv-button>
|
|
54
|
+
<uv-button type="primary" :plain="true" text="镂空"></uv-button>
|
|
55
|
+
<uv-button type="primary" :plain="true" :hairline="true" text="细边"></uv-button>
|
|
56
|
+
<uv-button type="primary" :disabled="disabled" text="禁用"></uv-button>
|
|
57
|
+
<uv-button type="primary" loading loadingText="加载中"></uv-button>
|
|
58
|
+
<uv-button type="primary" icon="map" text="图标按钮"></uv-button>
|
|
59
|
+
<uv-button type="primary" shape="circle" text="按钮形状"></uv-button>
|
|
60
|
+
<uv-button text="渐变色按钮" color="linear-gradient(to right, rgb(66, 83, 216), rgb(213, 51, 186))"></uv-button>
|
|
61
|
+
<uv-button type="primary" size="small" text="大小尺寸"></uv-button>
|
|
62
|
+
</view>
|
|
63
|
+
</template>
|
|
64
|
+
<script setup>
|
|
65
|
+
import { ref } from 'vue';
|
|
66
|
+
|
|
67
|
+
const disabled = ref(true);
|
|
68
|
+
|
|
69
|
+
</script>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 定义需要用到的外部样式
|
|
73
|
+
|
|
74
|
+
1. 针对非微信小程序平台,组件的根元素就是uni-app`button`组件,所以修改按钮的样式很容易,直接给组件定义`类名`或者嵌入`内联样式`即可。
|
|
75
|
+
2. 如果是微信小程序,编译后页面会有组件同名的元素存在,导致样式传递有问题。
|
|
76
|
+
3. 如果是为了修改按钮与其他元素之间的距离或者宽度等,可以给按钮外面套一个`view`元素,控制这个`view`与其他元素的距离或者宽度,即可达到同等效果。
|
|
77
|
+
|
|
78
|
+
所以:我们提供了一个`custom-style`参数,推荐用户可以用对象形式传递样式给组件内部,注意驼峰命名。
|
|
79
|
+
|
|
80
|
+
```vue
|
|
81
|
+
<template>
|
|
82
|
+
<view>
|
|
83
|
+
<uv-button :custom-style="customStyle" color="#fff" text="雪月夜"></uv-button>
|
|
84
|
+
</view>
|
|
85
|
+
</template>
|
|
86
|
+
<script setup>
|
|
87
|
+
import { computed } from 'vue';
|
|
88
|
+
|
|
89
|
+
const customStyle = computed(() => {
|
|
90
|
+
return {
|
|
91
|
+
height: '80rpx',
|
|
92
|
+
background: '#3c9cff',
|
|
93
|
+
color: '#fff',
|
|
94
|
+
borderRadius: '40rpx',
|
|
95
|
+
//圆角
|
|
96
|
+
// nvue中必须是下方的写法
|
|
97
|
+
'border-top-right-radius': '40rpx',
|
|
98
|
+
'border-bottom-left-radius': '40rpx',
|
|
99
|
+
'border-bottom-right-radius': '40rpx'
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
</script>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
### 各家小程序开放能力的对接
|
|
108
|
+
|
|
109
|
+
`uv-ui`已对接`uni-app`档关于[uni-app方button组件](https://uniapp.dcloud.net.cn/component/button)的所有开放能力(截止2023-06-29)`uni-app`文档说明使用即可,如果有发现遗漏的地方,请加群反馈。
|
|
110
|
+
|
|
111
|
+
### 完整示例
|
|
112
|
+
|
|
113
|
+
::: tip 完整示例下载地址
|
|
114
|
+
|
|
115
|
+
[https://ext.dcloud.net.cn/plugin?name=uv-ui](https://ext.dcloud.net.cn/plugin?name=uv-ui)
|
|
116
|
+
|
|
117
|
+
:::
|
|
118
|
+
|
|
119
|
+
### API
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### Button Props
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|属性名 |说明 |类型 |默认值 |可选值 |
|
|
126
|
+
|:- |:- |:- |:- |:- |
|
|
127
|
+
|hairline |是否显示按钮的细边框 |Boolean |true | true | false |
|
|
128
|
+
|type |按钮的样式类型 |String |info |info | primary | error | warning | success |
|
|
129
|
+
|size |按钮的大小 |String |normal |normal | large | mini |
|
|
130
|
+
|shape |按钮外观形状,见[上方说明](/components/button.html#设置按钮的多种形态) |String |square |square | circle |
|
|
131
|
+
|plain |按钮是否镂空,背景色透明 |Boolean |false |true | false |
|
|
132
|
+
|disabled |是否禁用 |Boolean |false |true | false |
|
|
133
|
+
|loading |按钮名称前是否带 loading 图标 |Boolean |false |true | false |App-nvue 平台,在 ios 上为雪花,Android上为圆圈|
|
|
134
|
+
|loadingText |加载中提示文字 |String |- |- |
|
|
135
|
+
|loadingMode |加载状态图标类型 |String |spinner| 更多值参考[LoadingIcon模式类型](https://www.uvui.cn/components/loadingIcon.html#%E6%A8%A1%E5%BC%8F%E7%B1%BB%E5%9E%8B) |
|
|
136
|
+
|loadingSize |加载图标大小 |String | Number |15 |- |
|
|
137
|
+
|openType |开放能力,具体请看uniapp稳定关于button组件部分说明[uni-app方button组件](https://uniapp.dcloud.net.cn/component/button) |String |- |- |
|
|
138
|
+
|formType |用于 \<form\> 组件,点击分别会触发 \<form\> 组件的 submit/reset 事件 |String |- |- |
|
|
139
|
+
|appParameter |打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效 (注:只微信小程序、QQ小程序有效) |String |- |- |
|
|
140
|
+
|hoverStopPropagation |指定是否阻止本节点的祖先节点出现点击态,微信小程序有效(默认 true) |Boolean |true | true | false |
|
|
141
|
+
|lang |指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文 |String |en |- |
|
|
142
|
+
|sessionFrom |会话来源,openType="contact"时有效 |String |- |- |
|
|
143
|
+
|sendMessageTitle |会话内消息卡片标题,openType="contact"时有效 |String |- |- |
|
|
144
|
+
|sendMessagePath |会话内消息卡片点击跳转小程序路径,openType="contact"时有效 |String |- |- |
|
|
145
|
+
|sendMessageImg |会话内消息卡片图片,openType="contact"时有效 |String |- |- |
|
|
146
|
+
|showMessageCard |是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示,用户点击后可以快速发送小程序消息,openType="contact"时有效 |String |- |- |- |
|
|
147
|
+
|dataName |额外传参参数,用于小程序的data-xxx属性,通过target.dataset.name获取 |String |- |- |
|
|
148
|
+
|throttleTime |节流,一定时间内只能触发一次,单位毫秒 |String | Number |0 |- |
|
|
149
|
+
|hoverStartTime |按住后多久出现点击态,单位毫秒 |String | Number |0 |- |
|
|
150
|
+
|hoverStayTime |手指松开后点击态保留时间,单位毫秒 |String | Number |200 |- |
|
|
151
|
+
|text |按钮文字,之所以通过props传入,是因为slot传入的话(注:nvue中无法控制文字的样式) |String | Number |- |- |
|
|
152
|
+
|icon |按钮图标 |String |- |- |
|
|
153
|
+
|iconSize <badge text="1.0.9"/> |按钮图大小 |String | Number |- |- |
|
|
154
|
+
|iconColor |按钮颜色 |String | 在`plain=true`镂空状态下,颜色与边框保持一致,否则为白色(主题为info时为黑色#000000) |- |
|
|
155
|
+
|color |按钮颜色,支持传入linear-gradient渐变色 |String |- |- |
|
|
156
|
+
| customTextStyle | 自定义按钮文字的样式,避免设置customStyle设置覆盖不了样式的情况 | Object | String | - | - |
|
|
157
|
+
|customStyle |定义需要用到的外部样式,详细见上方文档 |Object | String |- |- |
|
|
158
|
+
|
|
159
|
+
### Button Events
|
|
160
|
+
|
|
161
|
+
**说明**:目前经测试(Hbuilder X 2.6.8),在H5,APP,可以直接对组件监听`tap`事件,等同组件内部发出的`click`事件效果,某些HX版本上,
|
|
162
|
+
微信小程序对组件使用`tap`事件可能无效,故建议对按钮组件的点击事件监听统一使用组件内部发出的`click`事件。
|
|
163
|
+
|
|
164
|
+
|属性名 |说明 |类型 |默认值 |平台差异说明 |
|
|
165
|
+
|:- |:- |:- |:- |:- |
|
|
166
|
+
|@click |按钮点击,请勿使用`@tap`点击事件,微信小程序无效,返回值为点击事件及参数 |Handler|- |- |
|
|
167
|
+
|@getphonenumber |获取用户手机号回调,open-type="getPhoneNumber"生效 |Handler|- |微信、支付宝、百度、抖音、快手、京东小程序 |
|
|
168
|
+
|@getuserinfo |用户点击该按钮时,会返回获取到的用户信息,从返回参数的detail中获取到的值同uni.getUserInfo,open-type="getUserInfo"生效 |Handler|- |微信、QQ、百度、快手、京东小程序 |
|
|
169
|
+
|@error |当使用开放能力时,发生错误的回调 ,open-type="launchApp"生效 |Handler|- |微信、QQ、快手、京东小程序 |
|
|
170
|
+
|@opensetting |从小程序打开 App 成功的回调,open-type="launchApp"生效 |Handler|- |微信、QQ、百度、快手、京东小程序 |
|
|
171
|
+
|@launchapp |打开 APP 成功的回调,open-type="launchApp"生效 |Handler|- |微信、QQ、快手、京东小程序 |
|
|
172
|
+
|@contact |客服消息回调,open-type="contact"生效 |Handler|- |微信、QQ、百度、快手小程序 |
|
|
173
|
+
|@chooseavatar |获取用户头像回调,open-type="chooseAvatar"生效 |Handler|- |微信小程序 |
|
|
174
|
+
|@agreeprivacyauthorization | 用户同意隐私协议事件回调,open-type="agreePrivacyAuthorization"时有效 |Handler|- |微信小程序2.33.0 |
|
|
175
|
+
|@addgroupapp |添加群应用的回调,open-type="addGroupApp"生效 |Handler|- |QQ小程序 |
|
|
176
|
+
|@chooseaddress |调起用户编辑并选择收货地址的回调,open-type="chooseAddress"生效 |Handler|- |百度小程序 |
|
|
177
|
+
|@chooseinvoicetitle |用户选择发票抬头的回调,open-type="chooseInvoiceTitle"生效 |Handler|- |百度小程序 |
|
|
178
|
+
|@subscribe |订阅消息授权回调,open-type="subscribe"生效 |Handler|- |百度小程序 |
|
|
179
|
+
|@login |登录回调,open-type="login"生效 |Handler|- |百度小程序|
|
|
180
|
+
|@im | 监听跳转IM的成功回调,open-type="im"生效 |Handler|- |抖音小程序2.68.0版本+ |
|
|
181
|
+
|
|
182
|
+
关于`open-type`属性的设置及回调详情,请参考`uniapp`官方提供的[button](https://uniapp.dcloud.net.cn/component/button.html#button)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
### Button Slots
|
|
186
|
+
|名称 | 说明 |
|
|
187
|
+
|:- |:- |
|
|
188
|
+
| default | 默认插槽,按钮文本,建议统一使用text参数,保证样式的统一性 |
|
|
189
|
+
| suffix | 后置插槽,方便在按钮文字后面增加图标等 |
|
|
190
|
+
|
|
191
|
+
<style scoped>
|
|
192
|
+
h3[id=button-slots] + table thead tr th:nth-child(2)
|
|
193
|
+
{
|
|
194
|
+
width: 80%;
|
|
195
|
+
}
|
|
196
|
+
</style>
|