@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,216 @@
|
|
|
1
|
+
## Switch 开关选择器 <to-api/>
|
|
2
|
+
|
|
3
|
+
<demo-model url="/pages/componentsB/switch/switch"></demo-model>
|
|
4
|
+
|
|
5
|
+
::: tip ✈
|
|
6
|
+
|
|
7
|
+
**组件名:uv-switch**
|
|
8
|
+
|
|
9
|
+
[点击下载&安装](https://ext.dcloud.net.cn/plugin?name=uv-switch)
|
|
10
|
+
|
|
11
|
+
:::
|
|
12
|
+
|
|
13
|
+
选择开关用于在打开和关闭状态之间进行切换。
|
|
14
|
+
|
|
15
|
+
### 平台兼容性
|
|
16
|
+
|
|
17
|
+
|App(vue)|App(nvue)|H5|小程序|VUE2|VUE3|
|
|
18
|
+
|:-:|:-:|:-:|:-:|:-:|:-:|
|
|
19
|
+
|√|√|√|√|√|√|
|
|
20
|
+
|
|
21
|
+
### 基础使用
|
|
22
|
+
|
|
23
|
+
通过`v-model`绑定一个`布尔值`变量,这个变量是双向绑定的,当用户开或关选择器的时候,在父组件的该值也会相应的变为`true`或者`false`,也就是说,
|
|
24
|
+
您不用监听`change`事件,也能知道选择器当前处于**开**或者**关**的状态。
|
|
25
|
+
|
|
26
|
+
我们为其提供了`加载中 禁用 自定义尺寸 自定义颜色 自定义样式 异步控制`等六种能力,并在以下案例中为您展示
|
|
27
|
+
|
|
28
|
+
```vue
|
|
29
|
+
<template>
|
|
30
|
+
<uv-switch v-model="value"></uv-switch>
|
|
31
|
+
</template>
|
|
32
|
+
<script setup>
|
|
33
|
+
import { ref } from 'vue';
|
|
34
|
+
|
|
35
|
+
const value = ref(true);
|
|
36
|
+
|
|
37
|
+
</script>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 加载中
|
|
41
|
+
|
|
42
|
+
设置`loading`属性,默认为`true`,可以让`switch`处于加载中的状态,这时`switch`是不可操作的,您可以通过`:loading='loading'`以动态设置加载状态
|
|
43
|
+
|
|
44
|
+
```vue
|
|
45
|
+
<template>
|
|
46
|
+
<view>
|
|
47
|
+
<uv-switch v-model="value" loading></uv-switch>
|
|
48
|
+
<uv-switch v-model="value2" loading></uv-switch>
|
|
49
|
+
</view>
|
|
50
|
+
</template>
|
|
51
|
+
<script setup>
|
|
52
|
+
import { ref } from 'vue';
|
|
53
|
+
|
|
54
|
+
const value = ref(false);
|
|
55
|
+
const value2 = ref(true);
|
|
56
|
+
|
|
57
|
+
</script>
|
|
58
|
+
```
|
|
59
|
+
### 禁用switch
|
|
60
|
+
|
|
61
|
+
设置`disabled`属性,默认为`true`,即可禁用某个组件,让用户无法点击,禁用分为两种状态:
|
|
62
|
+
|
|
63
|
+
- 一是关闭情况下的禁用,这时只显示一个白色的区域。
|
|
64
|
+
- 二是打开后再禁用,这时会在原有的颜色上加一个`opacity`透明度,但此时依然是不可操作的。
|
|
65
|
+
|
|
66
|
+
```vue
|
|
67
|
+
<template>
|
|
68
|
+
<view>
|
|
69
|
+
<uv-switch v-model="value" disabled></uv-switch>
|
|
70
|
+
<uv-switch v-model="value2" disabled></uv-switch>
|
|
71
|
+
</view>
|
|
72
|
+
</template>
|
|
73
|
+
<script setup>
|
|
74
|
+
import { ref } from 'vue';
|
|
75
|
+
|
|
76
|
+
const value = ref(false);
|
|
77
|
+
const value2 = ref(true);
|
|
78
|
+
|
|
79
|
+
</script>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
### 自定义尺寸
|
|
84
|
+
|
|
85
|
+
设置`size`属性,可以让您自定义`switch`的尺寸,可自定义单位
|
|
86
|
+
|
|
87
|
+
```vue
|
|
88
|
+
<template>
|
|
89
|
+
<view>
|
|
90
|
+
<uv-switch v-model="value" size="28"></uv-switch>
|
|
91
|
+
<uv-switch v-model="value2" size="20"></uv-switch>
|
|
92
|
+
<uv-switch v-model="value2" size="30rpx"></uv-switch>
|
|
93
|
+
</view>
|
|
94
|
+
</template>
|
|
95
|
+
<script setup>
|
|
96
|
+
import { ref } from 'vue';
|
|
97
|
+
|
|
98
|
+
const value = ref(false);
|
|
99
|
+
const value2 = ref(true);
|
|
100
|
+
|
|
101
|
+
</script>
|
|
102
|
+
```
|
|
103
|
+
### 自定义颜色
|
|
104
|
+
|
|
105
|
+
设置`activeColor`属性,可以让您自定义`switch`的颜色,支持多种设置方式,如:`activeColor="#f56c6c" activeColor="red" activeColor="rgb(0,0,0)" `
|
|
106
|
+
|
|
107
|
+
```vue
|
|
108
|
+
<template>
|
|
109
|
+
<view>
|
|
110
|
+
<uv-switch v-model="value" activeColor="#f56c6c"></uv-switch>
|
|
111
|
+
</view>
|
|
112
|
+
</template>
|
|
113
|
+
<script setup>
|
|
114
|
+
import { ref } from 'vue';
|
|
115
|
+
|
|
116
|
+
const value = ref(true);
|
|
117
|
+
|
|
118
|
+
</script>
|
|
119
|
+
```
|
|
120
|
+
### 自定义样式
|
|
121
|
+
|
|
122
|
+
同时设置`activeColor`和`inactiveColor`属性,可以让您自定义`switch`的样式,同样支持多种设置方式
|
|
123
|
+
|
|
124
|
+
```vue
|
|
125
|
+
<template>
|
|
126
|
+
<view>
|
|
127
|
+
<uv-switch v-model="value" inactive-color="#f3f4f6" active-color="#3c9cff"></uv-switch>
|
|
128
|
+
</view>
|
|
129
|
+
</template>
|
|
130
|
+
<script setup>
|
|
131
|
+
import { ref } from 'vue';
|
|
132
|
+
|
|
133
|
+
const value = ref(false);
|
|
134
|
+
|
|
135
|
+
</script>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 异步控制
|
|
139
|
+
|
|
140
|
+
异步控制场景,一般发生在用户打开或者关闭选择器时,需要本地或者向后端请求判断,是否允许用户打开或者关闭的场景。
|
|
141
|
+
同时您也可以组合使用,例如根据接口结果添加`disabled`,`loading`属性等
|
|
142
|
+
|
|
143
|
+
:::warning 注意
|
|
144
|
+
请添加`asyncChange`属性来支持异步控制操作,否则您将先操作`v-model`绑定的值,并失去控制效果
|
|
145
|
+
:::
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
```vue
|
|
149
|
+
<template>
|
|
150
|
+
<uv-switch v-model="value" asyncChange @change="asyncChange"></uv-switch>
|
|
151
|
+
</template>
|
|
152
|
+
<script setup>
|
|
153
|
+
import { ref } from 'vue';
|
|
154
|
+
|
|
155
|
+
const value = ref(true);
|
|
156
|
+
function asyncChange(e) {
|
|
157
|
+
uni.showModal({
|
|
158
|
+
content: e ? '确定要打开吗' : '确定要关闭吗',
|
|
159
|
+
success: res => {
|
|
160
|
+
if (res.confirm) {
|
|
161
|
+
value.value = e;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
</script>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### 完整示例
|
|
171
|
+
|
|
172
|
+
::: tip 完整示例下载地址
|
|
173
|
+
|
|
174
|
+
[https://ext.dcloud.net.cn/plugin?name=uv-ui](https://ext.dcloud.net.cn/plugin?name=uv-ui)
|
|
175
|
+
|
|
176
|
+
:::
|
|
177
|
+
|
|
178
|
+
### API
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
### Switch Props
|
|
182
|
+
|
|
183
|
+
- 注意:需要给`switch`组件通过`v-model`绑定一个布尔值,来初始化`switch`的状态,随后该值被双向绑定,
|
|
184
|
+
当用打开选择器时,该值在`switch`组件内部被修改为`true`,并反映到父组件,否则为`false`。换言之,您无需监听`switch`的`change`事件,也能
|
|
185
|
+
知道某一个`switch`是否被选中的状态。
|
|
186
|
+
- `v-model`绑定的值必须为`inactiveValue`、`activeValue`二者之一,且`inactiveValue`和`activeValue`的值不能相等。
|
|
187
|
+
|
|
188
|
+
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
|
189
|
+
|:- |:- |:- |:- |:- |
|
|
190
|
+
| v-model | 双向绑定的值,**注意:这里只能使用v-model,不能使用:value** | Boolean | String | Number | false | - |
|
|
191
|
+
| loading | 是否处于加载中 | Boolean | false | true | false |
|
|
192
|
+
| disabled | 是否禁用 | Boolean | false | true | false |
|
|
193
|
+
| size | 开关尺寸,单位rpx | String | Number | 25 | - |
|
|
194
|
+
| activeColor | 打开时的背景色 | String | #2979ff | - |
|
|
195
|
+
| inactiveColor | 关闭时的背景色 | String | #ffffff | - |
|
|
196
|
+
| activeValue | switch打开时的值 | Boolean | String | Number | true | - |
|
|
197
|
+
| inactiveValue | switch关闭时的值 | Boolean | String | Number | false | - |
|
|
198
|
+
| asyncChange | 是否开启异步变更,开启后需要手动控制输入值 | Boolean | false | true | false |
|
|
199
|
+
| space | 圆点与外边框的距离 | String | Number | 0 | - |
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
### Switch Events
|
|
203
|
+
|
|
204
|
+
|事件名 |说明 |回调参数 |
|
|
205
|
+
|:- |:- |:- |
|
|
206
|
+
| @change| 在`switch`打开或关闭时触发 | value:打开时为`activeValue`值,关闭时为`inactiveValue`值 |
|
|
207
|
+
| @input | 在`switch`打开或关闭时触发(没开启异步) | value:打开时为`activeValue`值,关闭时为`inactiveValue`值 |
|
|
208
|
+
|
|
209
|
+
<style scoped>
|
|
210
|
+
h3[id=switch-events] + table thead tr th:nth-child(2){
|
|
211
|
+
width: 40%;
|
|
212
|
+
}
|
|
213
|
+
h3[id=switch-events] + table thead tr th:nth-child(3){
|
|
214
|
+
width: 50%;
|
|
215
|
+
}
|
|
216
|
+
</style>
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
## Tabbar 底部导航栏 <to-api/>
|
|
2
|
+
|
|
3
|
+
<demo-model url="/pages/componentsD/tabbar/tabbar"></demo-model>
|
|
4
|
+
|
|
5
|
+
::: tip ✈
|
|
6
|
+
|
|
7
|
+
**组件名:uv-tabbar > uv-tabbar-item**
|
|
8
|
+
|
|
9
|
+
[点击下载&安装](https://ext.dcloud.net.cn/plugin?name=uv-tabbar)
|
|
10
|
+
|
|
11
|
+
:::
|
|
12
|
+
|
|
13
|
+
#### 优点:
|
|
14
|
+
|
|
15
|
+
此组件提供了自定义tabbar的能力,具有如下特点:
|
|
16
|
+
- 图标可以使用字体图标(内置图标和扩展图标)或者图片
|
|
17
|
+
- 可以动态切换菜单的数量以及配置
|
|
18
|
+
- 切换菜单之前,可以进行回调鉴权
|
|
19
|
+
- 可以设置角标或数字化提示
|
|
20
|
+
- 有效防止组件区域高度塌陷,无需给父元素额外的内边距或者外边距来避开导航的区域
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### 平台兼容性
|
|
24
|
+
|
|
25
|
+
|App(vue)|App(nvue)|H5|小程序|VUE2|VUE3|
|
|
26
|
+
|:-:|:-:|:-:|:-:|:-:|:-:|
|
|
27
|
+
|√|√|√|√(仅支持微信小程序,[原因](https://www.uvui.cn/components/problem.html#%E4%B8%83%E3%80%81uv-row%E3%80%81uv-grid%E7%AD%89%E7%BB%84%E4%BB%B6%E5%9C%A8%E7%99%BE%E5%BA%A6%E5%B0%8F%E7%A8%8B%E5%BA%8F%E3%80%81%E6%8A%96%E9%9F%B3%E5%B0%8F%E7%A8%8B%E5%BA%8F%E7%AD%89%E5%B9%B3%E5%8F%B0%E6%98%BE%E7%A4%BA%E5%BC%82%E5%B8%B8))|√|√|
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### 基本使用
|
|
31
|
+
|
|
32
|
+
推荐您使用`list`数组遍历循环,案例使用基础方式构建,请根据`click`事件回调进行后续逻辑操作。
|
|
33
|
+
|
|
34
|
+
``` vue
|
|
35
|
+
<template>
|
|
36
|
+
<uv-tabbar :value="value" @change="index=>value = index">
|
|
37
|
+
<uv-tabbar-item text="首页" icon="home"></uv-tabbar-item>
|
|
38
|
+
<uv-tabbar-item text="放映厅" icon="photo"></uv-tabbar-item>
|
|
39
|
+
<uv-tabbar-item text="直播" icon="play-right"></uv-tabbar-item>
|
|
40
|
+
<uv-tabbar-item text="我的" icon="account"></uv-tabbar-item>
|
|
41
|
+
</uv-tabbar>
|
|
42
|
+
</template>
|
|
43
|
+
<script setup>
|
|
44
|
+
import { ref } from 'vue';
|
|
45
|
+
|
|
46
|
+
const value = ref(0);
|
|
47
|
+
</script>
|
|
48
|
+
```
|
|
49
|
+
### 显示徽标
|
|
50
|
+
|
|
51
|
+
使用`dot`属性添加--小点--类型徽标,使用`badge`属性添加--数字--类型徽标。您也可以使用`:badge='badge'`动态设置徽标数量,
|
|
52
|
+
这在消息盒子的展示中是比较好用的功能,类似于`uniapp`的API `uni.setTabBarBadge`。
|
|
53
|
+
|
|
54
|
+
``` vue
|
|
55
|
+
<template>
|
|
56
|
+
<uv-tabbar :value="value" @change="index=>value = index">
|
|
57
|
+
<uv-tabbar-item text="首页" icon="home" dot></uv-tabbar-item>
|
|
58
|
+
<uv-tabbar-item text="放映厅" icon="photo" badge="3"></uv-tabbar-item>
|
|
59
|
+
<uv-tabbar-item text="直播" icon="play-right"></uv-tabbar-item>
|
|
60
|
+
<uv-tabbar-item text="我的" icon="account"></uv-tabbar-item>
|
|
61
|
+
</uv-tabbar>
|
|
62
|
+
</template>
|
|
63
|
+
<script setup>
|
|
64
|
+
import { ref } from 'vue';
|
|
65
|
+
|
|
66
|
+
const value = ref(0);
|
|
67
|
+
</script>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 匹配标签的名称
|
|
71
|
+
|
|
72
|
+
`uv-tabbar-item`标签设置了`name`属性,则`value`值也需要设置对应`name`的值。不设置`name`属性`@change`返回索引,设置返回对应`name`的值。
|
|
73
|
+
|
|
74
|
+
``` vue
|
|
75
|
+
<template>
|
|
76
|
+
<uv-tabbar :value="value" @change="name=>value = name">
|
|
77
|
+
<uv-tabbar-item text="首页" icon="home" name="home"></uv-tabbar-item>
|
|
78
|
+
<uv-tabbar-item text="放映厅" icon="photo" name="photo"></uv-tabbar-item>
|
|
79
|
+
<uv-tabbar-item text="直播" icon="play-right" name="play-right"></uv-tabbar-item>
|
|
80
|
+
<uv-tabbar-item text="我的" icon="account" name="account"></uv-tabbar-item>
|
|
81
|
+
</uv-tabbar>
|
|
82
|
+
</template>
|
|
83
|
+
<script setup>
|
|
84
|
+
import { ref } from 'vue';
|
|
85
|
+
|
|
86
|
+
const value = ref('photo');
|
|
87
|
+
</script>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 自定义图标
|
|
91
|
+
|
|
92
|
+
如您需要自定义图标,在`uv-tabbar-item`标签中使用插槽`active-icon`和`inactive-icon`来定义图标和颜色
|
|
93
|
+
|
|
94
|
+
::: warning 注意
|
|
95
|
+
1. 使用图片自定义图标需要自己设置图片的宽高
|
|
96
|
+
2. 一旦自定义图标,`uv-tabbar-item`标签上就不能设置`icon`属性,否则`icon`属性优先级更高
|
|
97
|
+
:::
|
|
98
|
+
|
|
99
|
+
``` vue
|
|
100
|
+
<template>
|
|
101
|
+
<uv-tabbar :value="value" @change="index=>value = index">
|
|
102
|
+
<uv-tabbar-item text="首页">
|
|
103
|
+
<template v-slot:active-icon>
|
|
104
|
+
<image class="icon" src="https://cdn.uviewui.com/uview/common/bell-selected.png"></image>
|
|
105
|
+
</template>
|
|
106
|
+
<template v-slot:inactive-icon>
|
|
107
|
+
<image class="icon" src="https://cdn.uviewui.com/uview/common/bell.png"></image>
|
|
108
|
+
</template>
|
|
109
|
+
</uv-tabbar-item>
|
|
110
|
+
<uv-tabbar-item text="放映厅" icon="photo"></uv-tabbar-item>
|
|
111
|
+
<uv-tabbar-item text="直播" icon="play-right"></uv-tabbar-item>
|
|
112
|
+
<uv-tabbar-item text="我的" icon="account"></uv-tabbar-item>
|
|
113
|
+
</uv-tabbar>
|
|
114
|
+
</template>
|
|
115
|
+
<script setup>
|
|
116
|
+
import { ref } from 'vue';
|
|
117
|
+
|
|
118
|
+
const value = ref(0);
|
|
119
|
+
</script>
|
|
120
|
+
<style scoped>
|
|
121
|
+
.icon {
|
|
122
|
+
width: 36rpx;
|
|
123
|
+
height: 36rpx;
|
|
124
|
+
}
|
|
125
|
+
</style>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 拦截切换事件(点击第二个标签)
|
|
129
|
+
|
|
130
|
+
在切换事件中,处理拦截事件或者您其他js操作逻辑。
|
|
131
|
+
``` vue
|
|
132
|
+
<template>
|
|
133
|
+
<uv-tabbar :value="value" @change="change">
|
|
134
|
+
<uv-tabbar-item text="首页" icon="home"></uv-tabbar-item>
|
|
135
|
+
<uv-tabbar-item text="放映厅" icon="photo"></uv-tabbar-item>
|
|
136
|
+
<uv-tabbar-item text="直播" icon="play-right"></uv-tabbar-item>
|
|
137
|
+
<uv-tabbar-item text="我的" icon="account"></uv-tabbar-item>
|
|
138
|
+
</uv-tabbar>
|
|
139
|
+
</template>
|
|
140
|
+
<script setup>
|
|
141
|
+
import { ref } from 'vue';
|
|
142
|
+
|
|
143
|
+
const value = ref(0);
|
|
144
|
+
|
|
145
|
+
function change(e) {
|
|
146
|
+
if (e === 1) {
|
|
147
|
+
uni.showToast({
|
|
148
|
+
icon: 'none',
|
|
149
|
+
title: '请您先登录'
|
|
150
|
+
});
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
value.value = e;
|
|
155
|
+
}
|
|
156
|
+
</script>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 边框
|
|
160
|
+
|
|
161
|
+
组件默认带了顶部边框,如果不需要,配置`border`为`false`即可。
|
|
162
|
+
|
|
163
|
+
```vue
|
|
164
|
+
<template>
|
|
165
|
+
<uv-tabbar :value="value" :border="false" @change="index=>value = index">
|
|
166
|
+
<uv-tabbar-item text="首页" icon="home"></uv-tabbar-item>
|
|
167
|
+
<uv-tabbar-item text="放映厅" icon="photo"></uv-tabbar-item>
|
|
168
|
+
<uv-tabbar-item text="直播" icon="play-right"></uv-tabbar-item>
|
|
169
|
+
<uv-tabbar-item text="我的" icon="account"></uv-tabbar-item>
|
|
170
|
+
</uv-tabbar>
|
|
171
|
+
</template>
|
|
172
|
+
<script setup>
|
|
173
|
+
import { ref } from 'vue';
|
|
174
|
+
|
|
175
|
+
const value = ref(0);
|
|
176
|
+
|
|
177
|
+
</script>
|
|
178
|
+
```
|
|
179
|
+
### 固定在底部(固定在屏幕最下方)
|
|
180
|
+
|
|
181
|
+
通过设置`fixed`为`true`,该属性默认为`true`,与原生效果无异,但您可以按照api配置您需要的其他配置,如徽标,边框等
|
|
182
|
+
|
|
183
|
+
```vue
|
|
184
|
+
<template>
|
|
185
|
+
<uv-tabbar :value="value" :fixed="true" @change="index=>value = index">
|
|
186
|
+
<uv-tabbar-item text="首页" icon="home"></uv-tabbar-item>
|
|
187
|
+
<uv-tabbar-item text="放映厅" icon="photo"></uv-tabbar-item>
|
|
188
|
+
<uv-tabbar-item text="直播" icon="play-right"></uv-tabbar-item>
|
|
189
|
+
<uv-tabbar-item text="我的" icon="account"></uv-tabbar-item>
|
|
190
|
+
</uv-tabbar>
|
|
191
|
+
</template>
|
|
192
|
+
<script setup>
|
|
193
|
+
import { ref } from 'vue';
|
|
194
|
+
|
|
195
|
+
const value = ref(0);
|
|
196
|
+
|
|
197
|
+
</script>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### 完整示例
|
|
201
|
+
|
|
202
|
+
::: tip 完整示例下载地址
|
|
203
|
+
|
|
204
|
+
[https://ext.dcloud.net.cn/plugin?name=uv-ui](https://ext.dcloud.net.cn/plugin?name=uv-ui)
|
|
205
|
+
|
|
206
|
+
:::
|
|
207
|
+
|
|
208
|
+
### API
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
### TabBar Props
|
|
212
|
+
|
|
213
|
+
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
|
214
|
+
|:- |:- |:- |:- |:- |
|
|
215
|
+
| value | 当前匹配项的index。`TabBarItem`设置了`name`属性则匹配的`name` | String | Number | null | - |
|
|
216
|
+
| safeAreaInsetBottom | 是否为iPhoneX留出底部安全距离 | Boolean | true | true | false |
|
|
217
|
+
| border | 是否显示上方边框 | Boolean | true | true | false |
|
|
218
|
+
| zIndex | 元素层级`z-index` | String | Number | 1 | - |
|
|
219
|
+
| activeColor | 选中标签的颜色 | String | #1989fa | - |
|
|
220
|
+
| inactiveColor | 未选中标签的颜色 | String | #7d7e80 | - |
|
|
221
|
+
| fixed | 是否固定在底部 | Boolean | true | true | false |
|
|
222
|
+
| placeholder | `fixed`定位固定在底部时,是否生成一个等高元素防止塌陷 | Boolean | true | true | false |
|
|
223
|
+
| iconSize | 图标大小,自定义图片图标设置该属性无效 | String | Number | 20 | - |
|
|
224
|
+
| customStyle | 自定义样式 | Object | - | - |
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
### TabBarItem Props
|
|
228
|
+
|
|
229
|
+
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
|
230
|
+
|:- |:- |:- |:- |:- |
|
|
231
|
+
| name | `item`标签的名称,作为与`uv-tabbar`的`value`参数匹配的标识符 | String | Number | null | - |
|
|
232
|
+
| icon | `uv-ui`内置图标或者绝对路径的图片 | String | - | - |
|
|
233
|
+
| iconSize | 图标大小 | String | Number | 20 | - |
|
|
234
|
+
| badge | 右上角的角标提示信息 | String | Number | null | - |
|
|
235
|
+
| dot | 是否显示圆点,将会覆盖badge参数 | Boolean | false | true | false |
|
|
236
|
+
| text | 描述文本 | String | - | - |
|
|
237
|
+
| badgeStyle| 控制徽标的位置,对象或者字符串形式,可以设置`top`和`right`属性 | Object | String | 'top: 6px;right:2px;' | - |
|
|
238
|
+
|
|
239
|
+
### TabBar Events
|
|
240
|
+
|
|
241
|
+
| 事件名 | 说明 | 回调参数 |
|
|
242
|
+
| :- | :- | :- |
|
|
243
|
+
| @change| 切换选项时触发 | index:当前要切换项的index或name |
|
|
244
|
+
|
|
245
|
+
### TabBarItem Events
|
|
246
|
+
|
|
247
|
+
| 事件名 | 说明 | 回调参数 |
|
|
248
|
+
| :- | :- | :- |
|
|
249
|
+
| @click | 切换选项时触发 | index:当前要切换项的index或name |
|
|
250
|
+
|
|
251
|
+
### TabBarItem Slots
|
|
252
|
+
|名称 | 说明 |
|
|
253
|
+
|:- |:- |
|
|
254
|
+
| active-icon | 选中项的图标处自定义内容插槽 |
|
|
255
|
+
| inactive-icon | 未选中项的图标处自定义内容插槽 |
|
|
256
|
+
| text | tab项自定义文本插槽 |
|
|
257
|
+
|
|
258
|
+
<style scoped>
|
|
259
|
+
h3[id=tabbaritem-slots] + table thead tr th:nth-child(2)
|
|
260
|
+
{
|
|
261
|
+
width: 80%;
|
|
262
|
+
}
|
|
263
|
+
</style>
|