@fredwsw/frontend-rules 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +302 -0
  2. package/bin/cli.js +155 -0
  3. package/package.json +22 -0
  4. package/template/docs/uv-ui-docs/action-sheet-cn.md +180 -0
  5. package/template/docs/uv-ui-docs/album-cn.md +104 -0
  6. package/template/docs/uv-ui-docs/alert-cn.md +71 -0
  7. package/template/docs/uv-ui-docs/avatar-cn.md +149 -0
  8. package/template/docs/uv-ui-docs/back-top-cn.md +121 -0
  9. package/template/docs/uv-ui-docs/badge-cn.md +100 -0
  10. package/template/docs/uv-ui-docs/button-cn.md +181 -0
  11. package/template/docs/uv-ui-docs/calendar-cn.md +179 -0
  12. package/template/docs/uv-ui-docs/calendars-cn.md +264 -0
  13. package/template/docs/uv-ui-docs/cell-cn.md +163 -0
  14. package/template/docs/uv-ui-docs/checkbox-cn.md +164 -0
  15. package/template/docs/uv-ui-docs/code-cn.md +122 -0
  16. package/template/docs/uv-ui-docs/code-input-cn.md +127 -0
  17. package/template/docs/uv-ui-docs/collapse-cn.md +206 -0
  18. package/template/docs/uv-ui-docs/color-cn.md +122 -0
  19. package/template/docs/uv-ui-docs/count-down-cn.md +169 -0
  20. package/template/docs/uv-ui-docs/count-to-cn.md +125 -0
  21. package/template/docs/uv-ui-docs/datetime-picker-cn.md +167 -0
  22. package/template/docs/uv-ui-docs/divider-cn.md +90 -0
  23. package/template/docs/uv-ui-docs/drop-down-cn.md +287 -0
  24. package/template/docs/uv-ui-docs/empty-cn.md +76 -0
  25. package/template/docs/uv-ui-docs/form-cn.md +220 -0
  26. package/template/docs/uv-ui-docs/gap-cn.md +63 -0
  27. package/template/docs/uv-ui-docs/grid-cn.md +187 -0
  28. package/template/docs/uv-ui-docs/icon-cn.md +255 -0
  29. package/template/docs/uv-ui-docs/image-cn.md +170 -0
  30. package/template/docs/uv-ui-docs/index-list-cn.md +132 -0
  31. package/template/docs/uv-ui-docs/input-cn.md +157 -0
  32. package/template/docs/uv-ui-docs/keyboard-cn.md +156 -0
  33. package/template/docs/uv-ui-docs/layout-cn.md +215 -0
  34. package/template/docs/uv-ui-docs/line-cn.md +77 -0
  35. package/template/docs/uv-ui-docs/line-progress-cn.md +132 -0
  36. package/template/docs/uv-ui-docs/link-cn.md +97 -0
  37. package/template/docs/uv-ui-docs/list-cn.md +185 -0
  38. package/template/docs/uv-ui-docs/load-more-cn.md +144 -0
  39. package/template/docs/uv-ui-docs/loading-icon-cn.md +125 -0
  40. package/template/docs/uv-ui-docs/loading-page-cn.md +85 -0
  41. package/template/docs/uv-ui-docs/modal-cn.md +212 -0
  42. package/template/docs/uv-ui-docs/navbar-cn.md +171 -0
  43. package/template/docs/uv-ui-docs/no-network-cn.md +112 -0
  44. package/template/docs/uv-ui-docs/notice-bar-cn.md +119 -0
  45. package/template/docs/uv-ui-docs/notify-cn.md +185 -0
  46. package/template/docs/uv-ui-docs/number-box-cn.md +131 -0
  47. package/template/docs/uv-ui-docs/overlay-cn.md +122 -0
  48. package/template/docs/uv-ui-docs/parse-cn.md +177 -0
  49. package/template/docs/uv-ui-docs/pick-color-cn.md +147 -0
  50. package/template/docs/uv-ui-docs/picker-cn.md +159 -0
  51. package/template/docs/uv-ui-docs/popup-cn.md +184 -0
  52. package/template/docs/uv-ui-docs/qrcode-cn.md +150 -0
  53. package/template/docs/uv-ui-docs/radio-cn.md +166 -0
  54. package/template/docs/uv-ui-docs/rate-cn.md +91 -0
  55. package/template/docs/uv-ui-docs/read-more-cn.md +191 -0
  56. package/template/docs/uv-ui-docs/scroll-list-cn.md +188 -0
  57. package/template/docs/uv-ui-docs/search-cn.md +107 -0
  58. package/template/docs/uv-ui-docs/skeleton-cn.md +101 -0
  59. package/template/docs/uv-ui-docs/skeletons-cn.md +312 -0
  60. package/template/docs/uv-ui-docs/slider-cn.md +98 -0
  61. package/template/docs/uv-ui-docs/steps-cn.md +158 -0
  62. package/template/docs/uv-ui-docs/sticky-cn.md +82 -0
  63. package/template/docs/uv-ui-docs/subsection-cn.md +161 -0
  64. package/template/docs/uv-ui-docs/swipe-action-cn.md +207 -0
  65. package/template/docs/uv-ui-docs/swiper-cn.md +247 -0
  66. package/template/docs/uv-ui-docs/switch-cn.md +136 -0
  67. package/template/docs/uv-ui-docs/tabbar-cn.md +224 -0
  68. package/template/docs/uv-ui-docs/tabs-cn.md +260 -0
  69. package/template/docs/uv-ui-docs/tags-cn.md +191 -0
  70. package/template/docs/uv-ui-docs/text-cn.md +178 -0
  71. package/template/docs/uv-ui-docs/textarea-cn.md +132 -0
  72. package/template/docs/uv-ui-docs/toast-cn.md +110 -0
  73. package/template/docs/uv-ui-docs/tooltip-cn.md +91 -0
  74. package/template/docs/uv-ui-docs/transition-cn.md +202 -0
  75. package/template/docs/uv-ui-docs/upload-cn.md +156 -0
  76. package/template/docs/uv-ui-docs/vtabs-cn.md +190 -0
  77. package/template/docs/uv-ui-docs/waterfall-cn.md +276 -0
  78. package/template/rules/common.mdc +90 -0
  79. package/template/rules/uv-ui-docs.mdc +111 -0
  80. package/template/skills/code-simplifier/SKILL.md +109 -0
  81. package/template/skills/frontend-design/SKILL.md +44 -0
@@ -0,0 +1,247 @@
1
+ ---
2
+ group: 轮播
3
+ category: Components
4
+ title: Swiper
5
+ subtitle: 轮播图
6
+ description: 导航轮播与 Banner 展示组件,支持标题、指示器、加载中、视频轮播、自定义指示器与卡片式效果。
7
+ demo:
8
+ cols: 2
9
+ ---
10
+
11
+ ## 何时使用 {#when-to-use}
12
+
13
+ `uv-swiper` 一般用于导航轮播、Banner 展示等场景,可开箱即用,特点包括:
14
+
15
+ - 自定义指示器模式,可配置指示器样式
16
+ - 支持 3D 卡片式轮播
17
+ - 支持显示标题、加载状态和嵌入视频
18
+
19
+ 注意:
20
+
21
+ - App vue、百度/支付宝/头条/QQ 小程序中原生 `swiper` 不支持内嵌 `video`、`map` 等原生组件;
22
+ 微信基础库 2.4.4+ 和 App nvue 2.1.5+ 支持内嵌原生组件。
23
+ - `uv-swiper` 基于 uni 官方 `swiper` 封装,更多特性可参考 uni 官方文档。
24
+
25
+ > 完整示例下载地址:[uv-ui 插件市场](https://ext.dcloud.net.cn/plugin?name=uv-ui)
26
+
27
+ ## 平台兼容性 {#platform}
28
+
29
+ | App(vue) | App(nvue) | H5 | 小程序 | VUE2 | VUE3 |
30
+ | --- | --- | --- | --- | --- | --- |
31
+ | √ | √ | √ | √ | √ | √ |
32
+
33
+ **组件名:** `uv-swiper`
34
+
35
+ ## 代码演示 {#examples}
36
+
37
+ ### 基本使用 {#basic}
38
+
39
+ 通过 `list` 传入轮播图列表,数组元素为图片地址字符串。
40
+
41
+ ```vue
42
+ <template>
43
+ <uv-swiper :list="list"></uv-swiper>
44
+ </template>
45
+
46
+ <script>
47
+ export default {
48
+ data() {
49
+ return {
50
+ list: [
51
+ 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
52
+ 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
53
+ 'https://cdn.uviewui.com/uview/swiper/swiper3.png'
54
+ ]
55
+ }
56
+ }
57
+ }
58
+ </script>
59
+ ```
60
+
61
+ ### 带标题 {#title}
62
+
63
+ 当 `list` 为对象数组时,可通过 `showTitle` 显示标题,并用 `keyName` 指定图片字段、`titleStyle` 控制标题样式。
64
+
65
+ ```vue
66
+ <template>
67
+ <uv-swiper
68
+ :list="list"
69
+ keyName="image"
70
+ showTitle
71
+ :title-style="{ color: 'red', textAlign: 'center' }"
72
+ :autoplay="false"
73
+ circular
74
+ ></uv-swiper>
75
+ </template>
76
+
77
+ <script>
78
+ export default {
79
+ data() {
80
+ return {
81
+ list: [
82
+ {
83
+ image: 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
84
+ title: '丙辰中秋,欢饮达旦,大醉,作此篇,兼怀子由'
85
+ },
86
+ {
87
+ image: 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
88
+ title: '明月几时有?把酒问青天'
89
+ },
90
+ {
91
+ image: 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
92
+ title: '不知天上宫阙,今夕是何年'
93
+ }
94
+ ]
95
+ }
96
+ }
97
+ }
98
+ </script>
99
+ ```
100
+
101
+ ### 带指示器 {#indicator}
102
+
103
+ 通过 `indicator` 开启指示器,`indicatorMode` 控制类型:`line / dot`。
104
+
105
+ ```vue
106
+ <template>
107
+ <uv-swiper :list="list" indicator indicatorMode="line" circular></uv-swiper>
108
+ </template>
109
+ ```
110
+
111
+ ### 加载中 {#loading}
112
+
113
+ 通过 `loading` 控制加载状态。
114
+
115
+ ```vue
116
+ <uv-swiper :list="[]" loading></uv-swiper>
117
+ ``>
118
+
119
+ ### 嵌入视频与指定类型 {#video}
120
+
121
+ `list` 元素可为包含 `url/title/poster` 的对象,并通过 `keyName="url"` 指定字段;
122
+ 必要时可通过 `type: 'video' | 'image'` 显式指定类型。
123
+
124
+ ```vue
125
+ <template>
126
+ <uv-swiper :list="list" keyName="url" :autoplay="false"></uv-swiper>
127
+ </template>
128
+
129
+ <script>
130
+ export default {
131
+ data() {
132
+ return {
133
+ list: [
134
+ {
135
+ url: 'https://cdn.uviewui.com/uview/resources/video.mp4',
136
+ title: '昨夜星辰昨夜风,画楼西畔桂堂东',
137
+ poster: 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
138
+ type: 'video'
139
+ },
140
+ {
141
+ url: 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
142
+ title: '身无彩凤双飞翼,心有灵犀一点通',
143
+ type: 'image'
144
+ }
145
+ ]
146
+ }
147
+ }
148
+ }
149
+ </script>
150
+ ```
151
+
152
+ ### 自定义指示器 {#custom-indicator}
153
+
154
+ 可通过 `indicator` 插槽自定义指示点或数字样式。
155
+
156
+ ```vue
157
+ <template>
158
+ <view class="uv-demo-block">
159
+ <text class="uv-demo-block__title">自定义指示器</text>
160
+ <uv-swiper :list="list1" @change="e => (current1 = e.current)" :autoplay="false">
161
+ <template v-slot:indicator>
162
+ <view class="indicator">
163
+ <view
164
+ class="indicator__dot"
165
+ v-for="(item, index) in list1"
166
+ :key="index"
167
+ :class="[index === current1 && 'indicator__dot--active']"
168
+ ></view>
169
+ </view>
170
+ </template>
171
+ </uv-swiper>
172
+ </view>
173
+ </template>
174
+ ```
175
+
176
+ ### 卡片式轮播 {#card}
177
+
178
+ 通过 `previousMargin / nextMargin / radius` 等参数实现卡片式轮播。
179
+
180
+ ```vue
181
+ <template>
182
+ <!-- #ifndef APP-NVUE || MP-TOUTIAO -->
183
+ <view class="uv-demo-block">
184
+ <text class="uv-demo-block__title">卡片式</text>
185
+ <uv-swiper
186
+ :list="list"
187
+ previousMargin="30"
188
+ nextMargin="30"
189
+ circular
190
+ :autoplay="false"
191
+ radius="5"
192
+ bgColor="#ffffff"
193
+ ></uv-swiper>
194
+ </view>
195
+ <!-- #endif -->
196
+ </template>
197
+ ```
198
+
199
+ ## API {#api}
200
+
201
+ ### Swiper Props {#props}
202
+
203
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 |
204
+ | --- | --- | --- | --- | --- |
205
+ | list | 轮播图数据 | Array | - | - |
206
+ | indicator | 是否显示面板指示器 | Boolean | false | true \| false |
207
+ | indicatorActiveColor | 指示器激活颜色 | String | #FFFFFF | - |
208
+ | indicatorInactiveColor | 指示器非激活颜色 | String | rgba(255, 255, 255, 0.35) | - |
209
+ | indicatorStyle | 指示器样式(支持 bottom/left/right 定位) | String \| Object | - | - |
210
+ | indicatorMode | 指示器模式 | String | line | line \| dot |
211
+ | autoplay | 是否自动切换 | Boolean | true | true \| false |
212
+ | current | 当前所在滑块 index | Number \| String | 0 | - |
213
+ | currentItemId | 当前滑块 item-id(不能与 current 同时指定) | String | - | - |
214
+ | interval | 自动切换时间间隔(ms) | String \| Number | 3000 | - |
215
+ | duration | 切换过程时间(ms,nvue 不支持) | String \| Number | 300 | - |
216
+ | circular | 播放到末尾后是否回到开头 | Boolean | false | true \| false |
217
+ | vertical | 是否纵向滑动 | Boolean | false | true \| false |
218
+ | previousMargin | 前边距(露出前一项一部分) | String \| Number | 0 | - |
219
+ | nextMargin | 后边距(露出后一项一部分) | String \| Number | 0 | - |
220
+ | acceleration | 是否根据滑动速度连续滑动多屏(仅支付宝小程序) | Boolean | false | true \| false |
221
+ | displayMultipleItems | 同时显示的滑块数量(nvue/支付宝不支持) | Number | 1 | - |
222
+ | easingFunction | 切换缓动动画类型(部分平台支持) | String | default | 参考官方 swiper |
223
+ | keyName | 对象数组中图片字段名 | String | url | - |
224
+ | imgMode | 图片裁剪模式(不建议使用 `widthFix`) | String | aspectFill | - |
225
+ | height | 组件高度 | String \| Number | 130 | - |
226
+ | bgColor | 背景颜色 | String | #f3f4f6 | - |
227
+ | radius | 圆角 | String \| Number | 4 | - |
228
+ | loading | 是否加载中 | Boolean | false | true \| false |
229
+ | showTitle | 是否显示标题(要求对象中有 `title`) | Boolean | false | - |
230
+ | titleStyle | 标题样式 | Object | - | - |
231
+
232
+ ### Swiper Events {#events}
233
+
234
+ | 事件名 | 说明 | 回调参数 |
235
+ | --- | --- | --- |
236
+ | @click | 点击轮播图触发 | index:点击的图片索引(从 0 开始) |
237
+ | @change | 轮播图切换时触发 | index:当前图片索引(从 0 开始) |
238
+
239
+ ### SwiperIndicator Props {#indicator-props}
240
+
241
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 |
242
+ | --- | --- | --- | --- | --- |
243
+ | length | 轮播长度 | String \| Number | 0 | - |
244
+ | current | 当前激活索引 | String \| Number | 0 | - |
245
+ | indicatorActiveColor | 指示器非激活颜色 | String | - | - |
246
+ | indicatorInactiveColor | 指示器激活颜色 | String | - | - |
247
+ | indicatorStyle | 指示器形式 | String | line | line \| dot |
@@ -0,0 +1,136 @@
1
+ ---
2
+ group: 表单
3
+ category: Components
4
+ title: Switch
5
+ subtitle: 开关选择器
6
+ description: 在打开和关闭状态之间切换,支持加载、禁用、自定义尺寸和颜色、异步控制等。
7
+ demo:
8
+ cols: 2
9
+ ---
10
+
11
+ ## 何时使用 {#when-to-use}
12
+
13
+ `uv-switch` 通过 `v-model` 绑定布尔值,用户切换时自动更新。无需监听 `change` 也能获取当前状态。
14
+
15
+ > 完整示例下载地址:[uv-ui 插件市场](https://ext.dcloud.net.cn/plugin?name=uv-ui)
16
+
17
+ ## 平台兼容性 {#platform}
18
+
19
+ | App(vue) | App(nvue) | H5 | 小程序 | VUE2 | VUE3 |
20
+ | --- | --- | --- | --- | --- | --- |
21
+ | √ | √ | √ | √ | √ | √ |
22
+
23
+ **组件名:** `uv-switch`
24
+
25
+ ## 注意事项 {#notice}
26
+
27
+ - `v-model` 绑定的值必须为 `inactiveValue`、`activeValue` 之一
28
+ - `inactiveValue` 与 `activeValue` 不能相等
29
+ - 需使用 `v-model`,不能使用 `:value`
30
+
31
+ ## 代码演示 {#examples}
32
+
33
+ ### 基本使用 {#basic}
34
+
35
+ ```vue
36
+ <template>
37
+ <uv-switch v-model="value"></uv-switch>
38
+ </template>
39
+ <script>
40
+ export default {
41
+ data() {
42
+ return { value: true }
43
+ }
44
+ }
45
+ </script>
46
+ ```
47
+
48
+ ### 加载中 {#loading}
49
+
50
+ ```vue
51
+ <uv-switch v-model="value" loading></uv-switch>
52
+ ```
53
+
54
+ ### 禁用 {#disabled}
55
+
56
+ ```vue
57
+ <uv-switch v-model="value" disabled></uv-switch>
58
+ <uv-switch v-model="value2" disabled></uv-switch>
59
+ ```
60
+
61
+ ### 自定义尺寸 {#size}
62
+
63
+ ```vue
64
+ <uv-switch v-model="value" size="28"></uv-switch>
65
+ <uv-switch v-model="value2" size="20"></uv-switch>
66
+ <uv-switch v-model="value2" size="30rpx"></uv-switch>
67
+ ```
68
+
69
+ ### 自定义颜色 {#active-color}
70
+
71
+ ```vue
72
+ <uv-switch v-model="value" activeColor="#f56c6c"></uv-switch>
73
+ ```
74
+
75
+ ### 自定义开关样式 {#custom-style}
76
+
77
+ ```vue
78
+ <uv-switch
79
+ v-model="value"
80
+ inactive-color="#f3f4f6"
81
+ active-color="#3c9cff"
82
+ ></uv-switch>
83
+ ```
84
+
85
+ ### 异步控制 {#async}
86
+
87
+ 需添加 `asyncChange`,否则会先更新 `v-model` 且无法控制。
88
+
89
+ ```vue
90
+ <template>
91
+ <uv-switch v-model="value" asyncChange @change="asyncChange"></uv-switch>
92
+ </template>
93
+ <script>
94
+ export default {
95
+ data() {
96
+ return { value: true }
97
+ },
98
+ methods: {
99
+ asyncChange(e) {
100
+ uni.showModal({
101
+ content: e ? '确定要打开吗' : '确定要关闭吗',
102
+ success: (res) => {
103
+ if (res.confirm) {
104
+ this.value = e
105
+ }
106
+ }
107
+ })
108
+ }
109
+ }
110
+ }
111
+ </script>
112
+ ```
113
+
114
+ ## API {#api}
115
+
116
+ ### Switch Props {#props}
117
+
118
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 |
119
+ | --- | --- | --- | --- | --- |
120
+ | v-model | 双向绑定值(只能 v-model) | Boolean \| String \| Number | false | - |
121
+ | loading | 是否加载中 | Boolean | false | true \| false |
122
+ | disabled | 是否禁用 | Boolean | false | true \| false |
123
+ | size | 开关尺寸 | String \| Number | 25 | - |
124
+ | activeColor | 打开时背景色 | String | #2979ff | - |
125
+ | inactiveColor | 关闭时背景色 | String | #ffffff | - |
126
+ | activeValue | 打开时的值 | Boolean \| String \| Number | true | - |
127
+ | inactiveValue | 关闭时的值 | Boolean \| String \| Number | false | - |
128
+ | asyncChange | 是否异步变更,开启需手动控制值 | Boolean | false | true \| false |
129
+ | space | 圆点与外边框距离 | String \| Number | 0 | - |
130
+
131
+ ### Switch Events {#events}
132
+
133
+ | 事件名 | 说明 | 回调参数 |
134
+ | --- | --- | --- |
135
+ | @change | 打开或关闭时 | value:打开为 activeValue,关闭为 inactiveValue |
136
+ | @input | 打开或关闭时(未开启异步) | value |
@@ -0,0 +1,224 @@
1
+ ---
2
+ group: 导航
3
+ category: Components
4
+ title: Tabbar
5
+ subtitle: 底部导航栏
6
+ description: 自定义底部导航栏组件,支持字体图标/图片图标、徽标、动态菜单及切换拦截等能力。
7
+ demo:
8
+ cols: 2
9
+ ---
10
+
11
+ ## 何时使用 {#when-to-use}
12
+
13
+ `uv-tabbar` 提供自定义 Tabbar 的能力,用于 App/H5/小程序等多端统一的底部导航:
14
+
15
+ - 图标支持字体图标(内置/扩展)或图片
16
+ - 菜单可动态增减
17
+ - 切换前可拦截(鉴权等场景)
18
+ - 支持角标/数字徽标
19
+ - 有效防止底部区域高度塌陷
20
+
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-tabbar`、`uv-tabbar-item`
30
+
31
+ ## 代码演示 {#examples}
32
+
33
+ ### 基本使用 {#basic}
34
+
35
+ 推荐使用 `list` 数组循环构建,这里先展示基础写法,通过 `value` + `@change` 控制当前选中项。
36
+
37
+ ```vue
38
+ <template>
39
+ <uv-tabbar :value="value" @change="index => (value = index)">
40
+ <uv-tabbar-item text="首页" icon="home"></uv-tabbar-item>
41
+ <uv-tabbar-item text="放映厅" icon="photo"></uv-tabbar-item>
42
+ <uv-tabbar-item text="直播" icon="play-right"></uv-tabbar-item>
43
+ <uv-tabbar-item text="我的" icon="account"></uv-tabbar-item>
44
+ </uv-tabbar>
45
+ </template>
46
+
47
+ <script>
48
+ export default {
49
+ data() {
50
+ return {
51
+ value: 0
52
+ }
53
+ }
54
+ }
55
+ </script>
56
+ ```
57
+
58
+ ### 显示徽标 {#badge}
59
+
60
+ 通过 `dot` 添加小圆点,通过 `badge` 添加数字徽标。
61
+
62
+ ```vue
63
+ <template>
64
+ <uv-tabbar :value="value" @change="index => (value = index)">
65
+ <uv-tabbar-item text="首页" icon="home" dot></uv-tabbar-item>
66
+ <uv-tabbar-item text="放映厅" icon="photo" badge="3"></uv-tabbar-item>
67
+ <uv-tabbar-item text="直播" icon="play-right"></uv-tabbar-item>
68
+ <uv-tabbar-item text="我的" icon="account"></uv-tabbar-item>
69
+ </uv-tabbar>
70
+ </template>
71
+ ```
72
+
73
+ ### 使用 name 匹配标签 {#name}
74
+
75
+ 当 `uv-tabbar-item` 设置了 `name` 时,`value` 也需要使用同名值;`@change` 返回 `name`。
76
+
77
+ ```vue
78
+ <template>
79
+ <uv-tabbar :value="value" @change="name => (value = name)">
80
+ <uv-tabbar-item text="首页" icon="home" name="home"></uv-tabbar-item>
81
+ <uv-tabbar-item text="放映厅" icon="photo" name="photo"></uv-tabbar-item>
82
+ <uv-tabbar-item text="直播" icon="play-right" name="play-right"></uv-tabbar-item>
83
+ <uv-tabbar-item text="我的" icon="account" name="account"></uv-tabbar-item>
84
+ </uv-tabbar>
85
+ </template>
86
+
87
+ <script>
88
+ export default {
89
+ data() {
90
+ return {
91
+ value: 'photo'
92
+ }
93
+ }
94
+ }
95
+ </script>
96
+ ```
97
+
98
+ ### 自定义图标 {#custom-icon}
99
+
100
+ 通过 `active-icon` / `inactive-icon` 插槽自定义图标,一旦自定义,`icon` 属性将不再生效。
101
+
102
+ ```vue
103
+ <template>
104
+ <uv-tabbar :value="value" @change="index => (value = index)">
105
+ <uv-tabbar-item text="首页">
106
+ <template v-slot:active-icon>
107
+ <image class="icon" src="https://cdn.uviewui.com/uview/common/bell-selected.png"></image>
108
+ </template>
109
+ <template v-slot:inactive-icon>
110
+ <image class="icon" src="https://cdn.uviewui.com/uview/common/bell.png"></image>
111
+ </template>
112
+ </uv-tabbar-item>
113
+ <uv-tabbar-item text="放映厅" icon="photo"></uv-tabbar-item>
114
+ <uv-tabbar-item text="直播" icon="play-right"></uv-tabbar-item>
115
+ <uv-tabbar-item text="我的" icon="account"></uv-tabbar-item>
116
+ </uv-tabbar>
117
+ </template>
118
+
119
+ <style scoped>
120
+ .icon {
121
+ width: 36rpx;
122
+ height: 36rpx;
123
+ }
124
+ </style>
125
+ ```
126
+
127
+ ### 拦截切换事件 {#intercept}
128
+
129
+ 通过 `@change` 回调可以实现登录拦截等逻辑。
130
+
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
+
141
+ <script>
142
+ export default {
143
+ data() {
144
+ return {
145
+ value: 0
146
+ }
147
+ },
148
+ methods: {
149
+ change(e) {
150
+ if (e === 1) {
151
+ return uni.showToast({
152
+ icon: 'none',
153
+ title: '请您先登录'
154
+ })
155
+ }
156
+ this.value = e
157
+ }
158
+ }
159
+ }
160
+ </script>
161
+ ```
162
+
163
+ ### 去除顶部边框与固定在底部 {#border-fixed}
164
+
165
+ ```vue
166
+ <!-- 无边框 -->
167
+ <uv-tabbar :value="value" :border="false" @change="index => (value = index)">
168
+ ...
169
+ </uv-tabbar>
170
+
171
+ <!-- 固定在屏幕底部(默认 fixed=true) -->
172
+ <uv-tabbar :value="value" :fixed="true" @change="index => (value = index)">
173
+ ...
174
+ </uv-tabbar>
175
+ ```
176
+
177
+ ## API {#api}
178
+
179
+ ### TabBar Props {#tabbar-props}
180
+
181
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 |
182
+ | --- | --- | --- | --- | --- |
183
+ | value | 当前匹配项的 index 或 name(当子项设置 `name` 时按 name 匹配) | String \| Number | null | - |
184
+ | safeAreaInsetBottom | 是否为 iPhone X 留出底部安全距离 | Boolean | true | true \| false |
185
+ | border | 是否显示上方边框 | Boolean | true | true \| false |
186
+ | zIndex | 元素层级 `z-index` | String \| Number | 1 | - |
187
+ | activeColor | 选中标签颜色 | String | #1989fa | - |
188
+ | inactiveColor | 未选中标签颜色 | String | #7d7e80 | - |
189
+ | fixed | 是否固定在底部 | Boolean | true | true \| false |
190
+ | placeholder | `fixed` 时是否生成等高占位元素防止塌陷 | Boolean | true | true \| false |
191
+ | iconSize | 图标大小(自定义图片图标无效) | String \| Number | 20 | - |
192
+ | customStyle | 自定义样式 | Object | - | - |
193
+
194
+ ### TabBarItem Props {#tabbar-item-props}
195
+
196
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 |
197
+ | --- | --- | --- | --- | --- |
198
+ | name | 标签名称(与 `value` 匹配) | String \| Number | null | - |
199
+ | icon | 内置图标或图片地址 | String | - | - |
200
+ | iconSize | 图标大小 | String \| Number | 20 | - |
201
+ | badge | 右上角徽标内容 | String \| Number | null | - |
202
+ | dot | 是否显示圆点(会覆盖 `badge`) | Boolean | false | true \| false |
203
+ | text | 描述文本 | String | - | - |
204
+ | badgeStyle | 徽标位置样式(可设置 top/right) | Object \| String | `top: 6px;right:2px;` | - |
205
+
206
+ ### TabBar Events {#tabbar-events}
207
+
208
+ | 事件名 | 说明 | 回调参数 |
209
+ | --- | --- | --- |
210
+ | @change | 切换选项时触发 | index:当前要切换项的 index 或 name |
211
+
212
+ ### TabBarItem Events {#tabbar-item-events}
213
+
214
+ | 事件名 | 说明 | 回调参数 |
215
+ | --- | --- | --- |
216
+ | @click | 点击某个选项时触发 | index:当前要切换项的 index 或 name |
217
+
218
+ ### TabBarItem Slots {#tabbar-item-slots}
219
+
220
+ | 名称 | 说明 |
221
+ | --- | --- |
222
+ | active-icon | 选中状态自定义图标 |
223
+ | inactive-icon | 未选中状态自定义图标 |
224
+ | text | 自定义文本内容 |