@tuya-miniapp/smart-ui 2.13.1 → 2.13.2-beta-1
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/dist/action-sheet/README.md +631 -0
- package/dist/battery/README.md +102 -0
- package/dist/bottom-sheet/README.md +397 -0
- package/dist/button/README.md +205 -0
- package/dist/button/index.css +1 -1
- package/dist/button/index.wxss +1 -1
- package/dist/calendar/README.md +466 -0
- package/dist/cascader/README.md +235 -0
- package/dist/cell/README.md +240 -0
- package/dist/checkbox/README.md +359 -0
- package/dist/circle/README.md +116 -0
- package/dist/col/README.md +134 -0
- package/dist/collapse/README.md +223 -0
- package/dist/common/README.md +71 -0
- package/dist/config-provider/README.md +143 -0
- package/dist/count-down/README.md +194 -0
- package/dist/custom-keyboard/README.md +119 -0
- package/dist/datetime-picker/README.md +384 -0
- package/dist/dialog/README.md +412 -0
- package/dist/divider/README.md +100 -0
- package/dist/dropdown-menu/README.md +278 -0
- package/dist/empty/README.md +101 -0
- package/dist/field/README.md +439 -0
- package/dist/grid/README.md +197 -0
- package/dist/icon/README.md +143 -0
- package/dist/image/README.md +171 -0
- package/dist/index-bar/README.md +189 -0
- package/dist/loading/README.md +86 -0
- package/dist/nav-bar/README.md +378 -0
- package/dist/normal-slider/README.md +325 -0
- package/dist/notice-bar/README.md +216 -0
- package/dist/notify/README.md +120 -0
- package/dist/overlay/README.md +132 -0
- package/dist/picker/README.md +396 -0
- package/dist/popover/README.md +249 -0
- package/dist/popup/README.md +162 -0
- package/dist/progress/README.md +99 -0
- package/dist/radio/README.md +303 -0
- package/dist/rate/README.md +176 -0
- package/dist/search/README.md +235 -0
- package/dist/sidebar/README.md +160 -0
- package/dist/skeleton/README.md +98 -0
- package/dist/slider/README.md +366 -0
- package/dist/stepper/README.md +208 -0
- package/dist/stepper/index.js +16 -1
- package/dist/stepper/index.wxml +1 -1
- package/dist/sticky/README.md +124 -0
- package/dist/swipe-cell/README.md +172 -0
- package/dist/switch/README.md +204 -0
- package/dist/tab/README.md +414 -0
- package/dist/tabbar/README.md +333 -0
- package/dist/tag/README.md +184 -0
- package/dist/toast/README.md +220 -0
- package/dist/transition/README.md +114 -0
- package/dist/tree-select/README.md +199 -0
- package/lib/action-sheet/README.md +631 -0
- package/lib/battery/README.md +102 -0
- package/lib/bottom-sheet/README.md +397 -0
- package/lib/button/README.md +205 -0
- package/lib/button/index.css +1 -1
- package/lib/button/index.wxss +1 -1
- package/lib/calendar/README.md +466 -0
- package/lib/cascader/README.md +235 -0
- package/lib/cell/README.md +240 -0
- package/lib/checkbox/README.md +359 -0
- package/lib/circle/README.md +116 -0
- package/lib/col/README.md +134 -0
- package/lib/collapse/README.md +223 -0
- package/lib/common/README.md +71 -0
- package/lib/config-provider/README.md +143 -0
- package/lib/count-down/README.md +194 -0
- package/lib/custom-keyboard/README.md +119 -0
- package/lib/datetime-picker/README.md +384 -0
- package/lib/dialog/README.md +412 -0
- package/lib/divider/README.md +100 -0
- package/lib/dropdown-menu/README.md +278 -0
- package/lib/empty/README.md +101 -0
- package/lib/field/README.md +439 -0
- package/lib/grid/README.md +197 -0
- package/lib/icon/README.md +143 -0
- package/lib/image/README.md +171 -0
- package/lib/index-bar/README.md +189 -0
- package/lib/loading/README.md +86 -0
- package/lib/nav-bar/README.md +378 -0
- package/lib/normal-slider/README.md +325 -0
- package/lib/notice-bar/README.md +216 -0
- package/lib/notify/README.md +120 -0
- package/lib/overlay/README.md +132 -0
- package/lib/picker/README.md +396 -0
- package/lib/popover/README.md +249 -0
- package/lib/popup/README.md +162 -0
- package/lib/progress/README.md +99 -0
- package/lib/radio/README.md +303 -0
- package/lib/rate/README.md +176 -0
- package/lib/search/README.md +235 -0
- package/lib/sidebar/README.md +160 -0
- package/lib/skeleton/README.md +98 -0
- package/lib/slider/README.md +366 -0
- package/lib/stepper/README.md +208 -0
- package/lib/stepper/index.js +16 -1
- package/lib/stepper/index.wxml +1 -1
- package/lib/sticky/README.md +124 -0
- package/lib/swipe-cell/README.md +172 -0
- package/lib/switch/README.md +204 -0
- package/lib/tab/README.md +414 -0
- package/lib/tabbar/README.md +333 -0
- package/lib/tag/README.md +184 -0
- package/lib/toast/README.md +220 -0
- package/lib/transition/README.md +114 -0
- package/lib/tree-select/README.md +199 -0
- package/package.json +5 -4
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: 导航
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Tabbar 标签栏
|
|
6
|
+
|
|
7
|
+
### 介绍
|
|
8
|
+
|
|
9
|
+
底部导航栏,用于在不同页面之间进行切换。
|
|
10
|
+
|
|
11
|
+
### 引入
|
|
12
|
+
|
|
13
|
+
在`app.json`或`index.json`中引入组件,详细介绍见[快速上手](/material/smartui?comId=help-getting-started&appType=miniapp)。
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
"usingComponents": {
|
|
17
|
+
"smart-tabbar": "@tuya-miniapp/smart-ui/lib/tabbar/index",
|
|
18
|
+
"smart-tabbar-item": "@tuya-miniapp/smart-ui/lib/tabbar-item/index"
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 代码演示
|
|
23
|
+
|
|
24
|
+
### 基础用法
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<smart-tabbar active="{{ active }}" bind:change="onChange">
|
|
28
|
+
<smart-tabbar-item icon="home-o">标签</smart-tabbar-item>
|
|
29
|
+
<smart-tabbar-item icon="search">标签</smart-tabbar-item>
|
|
30
|
+
<smart-tabbar-item icon="friendsmart-o">标签</smart-tabbar-item>
|
|
31
|
+
<smart-tabbar-item icon="setting-o">标签</smart-tabbar-item>
|
|
32
|
+
</smart-tabbar>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
Page({
|
|
37
|
+
data: {
|
|
38
|
+
active: 0,
|
|
39
|
+
},
|
|
40
|
+
onChange(event) {
|
|
41
|
+
// event.detail 的值为当前选中项的索引
|
|
42
|
+
this.setData({ active: event.detail });
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 通过名称匹配
|
|
48
|
+
|
|
49
|
+
在标签指定`name`属性的情况下,`v-model`的值为当前标签的`name`。
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
<smart-tabbar active="{{ active }}" bind:change="onChange">
|
|
53
|
+
<smart-tabbar-item name="home" icon="home-o">标签</smart-tabbar-item>
|
|
54
|
+
<smart-tabbar-item name="search" icon="search">标签</smart-tabbar-item>
|
|
55
|
+
<smart-tabbar-item name="friends" icon="friendsmart-o">标签</smart-tabbar-item>
|
|
56
|
+
<smart-tabbar-item name="setting" icon="setting-o">标签</smart-tabbar-item>
|
|
57
|
+
</smart-tabbar>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
Page({
|
|
62
|
+
data: {
|
|
63
|
+
active: 'home',
|
|
64
|
+
},
|
|
65
|
+
onChange(event) {
|
|
66
|
+
this.setData({ active: event.detail });
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 显示徽标
|
|
72
|
+
|
|
73
|
+
```html
|
|
74
|
+
<smart-tabbar active="{{ active }}" bind:change="onChange">
|
|
75
|
+
<smart-tabbar-item icon="home-o">标签</smart-tabbar-item>
|
|
76
|
+
<smart-tabbar-item icon="search" dot>标签</smart-tabbar-item>
|
|
77
|
+
<smart-tabbar-item icon="friendsmart-o" info="5">标签</smart-tabbar-item>
|
|
78
|
+
<smart-tabbar-item icon="setting-o" info="20">标签</smart-tabbar-item>
|
|
79
|
+
</smart-tabbar>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 自定义图标
|
|
83
|
+
|
|
84
|
+
可以通过 slot 自定义图标,其中 icon slot 代表未选中状态下的图标,icon-active slot 代表选中状态下的图标。
|
|
85
|
+
|
|
86
|
+
```html
|
|
87
|
+
<smart-tabbar active="{{ active }}" bind:change="onChange">
|
|
88
|
+
<smart-tabbar-item info="3">
|
|
89
|
+
<image
|
|
90
|
+
slot="icon"
|
|
91
|
+
src="{{ icon.normal }}"
|
|
92
|
+
mode="aspectFit"
|
|
93
|
+
style="width: 30px; height: 18px;"
|
|
94
|
+
/>
|
|
95
|
+
<image
|
|
96
|
+
slot="icon-active"
|
|
97
|
+
src="{{ icon.active }}"
|
|
98
|
+
mode="aspectFit"
|
|
99
|
+
style="width: 30px; height: 18px;"
|
|
100
|
+
/>
|
|
101
|
+
自定义
|
|
102
|
+
</smart-tabbar-item>
|
|
103
|
+
<smart-tabbar-item icon="search">标签</smart-tabbar-item>
|
|
104
|
+
<smart-tabbar-item icon="setting-o">标签</smart-tabbar-item>
|
|
105
|
+
</smart-tabbar>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
Page({
|
|
110
|
+
data: {
|
|
111
|
+
active: 0,
|
|
112
|
+
icon: {
|
|
113
|
+
normal:
|
|
114
|
+
'https://static1.tuyacn.com/static/tuya-miniapp-doc/_next/static/images/logo-small.png',
|
|
115
|
+
active:
|
|
116
|
+
'https://static1.tuyacn.com/static/tuya-miniapp-doc/_next/static/images/logo-small.png',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
onChange(event) {
|
|
120
|
+
this.setData({ active: event.detail });
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### 自定义颜色
|
|
126
|
+
|
|
127
|
+
```html
|
|
128
|
+
<smart-tabbar
|
|
129
|
+
active="{{ active }}"
|
|
130
|
+
active-color="#07c160"
|
|
131
|
+
inactive-color="#000"
|
|
132
|
+
bind:change="onChange"
|
|
133
|
+
>
|
|
134
|
+
<smart-tabbar-item icon="home-o">标签</smart-tabbar-item>
|
|
135
|
+
<smart-tabbar-item icon="search">标签</smart-tabbar-item>
|
|
136
|
+
<smart-tabbar-item icon="friendsmart-o">标签</smart-tabbar-item>
|
|
137
|
+
<smart-tabbar-item icon="setting-o">标签</smart-tabbar-item>
|
|
138
|
+
</smart-tabbar>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
```javascript
|
|
142
|
+
Page({
|
|
143
|
+
data: {
|
|
144
|
+
active: 0,
|
|
145
|
+
},
|
|
146
|
+
onChange(event) {
|
|
147
|
+
this.setData({ active: event.detail });
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 切换标签事件
|
|
153
|
+
|
|
154
|
+
```html
|
|
155
|
+
<smart-tabbar active="{{ active }}" bind:change="onChange">
|
|
156
|
+
<smart-tabbar-item icon="home-o">标签1</smart-tabbar-item>
|
|
157
|
+
<smart-tabbar-item icon="search">标签2</smart-tabbar-item>
|
|
158
|
+
<smart-tabbar-item icon="friendsmart-o">标签3</smart-tabbar-item>
|
|
159
|
+
<smart-tabbar-item icon="setting-o">标签4</smart-tabbar-item>
|
|
160
|
+
</smart-tabbar>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
Page({
|
|
165
|
+
data: {
|
|
166
|
+
active: 0,
|
|
167
|
+
},
|
|
168
|
+
onClick(event) {
|
|
169
|
+
ty.showToast({
|
|
170
|
+
title: `点击标签 ${event.detail + 1}`,
|
|
171
|
+
icon: 'none',
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### 使用插槽
|
|
178
|
+
|
|
179
|
+
```html
|
|
180
|
+
<smart-tabbar
|
|
181
|
+
active="{{ active }}"
|
|
182
|
+
data-key="active"
|
|
183
|
+
custom-class="tabbar-position"
|
|
184
|
+
safe-area-inset-bottom="{{ false }}"
|
|
185
|
+
bind:change="onChange"
|
|
186
|
+
>
|
|
187
|
+
<image style="height: 40px;width:40px;margin: 6px 10px;" src="{{icon.left}}" slot="left" />
|
|
188
|
+
<smart-tabbar-item>
|
|
189
|
+
<smart-icon name="{{defaultIcon1}}" slot="icon" />
|
|
190
|
+
<smart-icon name="{{defaultIcon1}}" color="red" slot="icon-active" />
|
|
191
|
+
标签1
|
|
192
|
+
</smart-tabbar-item>
|
|
193
|
+
<smart-tabbar-item>
|
|
194
|
+
<smart-icon name="{{defaultIcon2}}" slot="icon" />
|
|
195
|
+
<smart-icon name="{{defaultIcon2}}" color="red" slot="icon-active" />
|
|
196
|
+
标签2
|
|
197
|
+
</smart-tabbar-item>
|
|
198
|
+
<smart-tabbar-item>
|
|
199
|
+
<smart-icon name="{{defaultIcon3}}" slot="icon" />
|
|
200
|
+
<smart-icon name="{{defaultIcon3}}" color="red" slot="icon-active" />
|
|
201
|
+
标签3
|
|
202
|
+
</smart-tabbar-item>
|
|
203
|
+
<smart-tabbar-item>
|
|
204
|
+
<smart-icon name="{{defaultIcon4}}" slot="icon" />
|
|
205
|
+
<smart-icon name="{{defaultIcon4}}" color="red" slot="icon-active" />
|
|
206
|
+
标签4
|
|
207
|
+
</smart-tabbar-item>
|
|
208
|
+
</smart-tabbar>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
```javascript
|
|
212
|
+
import Tornado from '@tuya-miniapp/icons/dist/svg/Tornado';
|
|
213
|
+
import Timer from '@tuya-miniapp/icons/dist/svg/Timer';
|
|
214
|
+
import TorSnownado from '@tuya-miniapp/icons/dist/svg/Snow';
|
|
215
|
+
import Connect from '@tuya-miniapp/icons/dist/svg/Connect';
|
|
216
|
+
|
|
217
|
+
Page({
|
|
218
|
+
data: {
|
|
219
|
+
active: 0,
|
|
220
|
+
icon: {
|
|
221
|
+
left: 'https://static1.tuyacn.com/static/tuya-miniapp-doc/_next/static/images/logo-small.png',
|
|
222
|
+
},
|
|
223
|
+
defaultIcon1: Tornado,
|
|
224
|
+
defaultIcon2: Timer,
|
|
225
|
+
defaultIcon3: TorSnownado,
|
|
226
|
+
defaultIcon4: Connect,
|
|
227
|
+
},
|
|
228
|
+
onChange(event) {
|
|
229
|
+
this.setData({ active: event.detail });
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### 上下颠倒 `v2.5.1`
|
|
235
|
+
|
|
236
|
+
`upside-down` 属性可以实现组件的上下样式颠倒,让标题在图标的上方。
|
|
237
|
+
|
|
238
|
+
```html
|
|
239
|
+
<smart-tabbar upside-down active="{{ active }}" bind:change="onChange">
|
|
240
|
+
<smart-tabbar-item icon="home-o">标签</smart-tabbar-item>
|
|
241
|
+
<smart-tabbar-item icon="search">标签</smart-tabbar-item>
|
|
242
|
+
<smart-tabbar-item icon="friendsmart-o">标签</smart-tabbar-item>
|
|
243
|
+
<smart-tabbar-item icon="setting-o">标签</smart-tabbar-item>
|
|
244
|
+
</smart-tabbar>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
```javascript
|
|
248
|
+
Page({
|
|
249
|
+
data: {
|
|
250
|
+
active: 0,
|
|
251
|
+
},
|
|
252
|
+
onChange(event) {
|
|
253
|
+
// event.detail 的值为当前选中项的索引
|
|
254
|
+
this.setData({ active: event.detail });
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### 结合自定义 tabBar
|
|
260
|
+
|
|
261
|
+
请参考 [微信官方文档](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/custom-tabbar.html) 与 [代码片段](https://developers.weixin.qq.com/s/vaXgTsmQ7hnm)。
|
|
262
|
+
|
|
263
|
+
## API
|
|
264
|
+
|
|
265
|
+
### Tabbar Props
|
|
266
|
+
|
|
267
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
268
|
+
| ---------------------- | -------------------------------------------------- | --------- | ------------------------------------------------------- |
|
|
269
|
+
| active | 当前选中标签的索引 | _number_ | - |
|
|
270
|
+
| active-color | 选中标签的颜色 | _string_ | `--tabbar-item-active-color` \| `--app-M1` \| `#3678e3` |
|
|
271
|
+
| border | 是否展示外边框 | _boolean_ | `true` |
|
|
272
|
+
| fixed | 是否固定在底部 | _boolean_ | `true` |
|
|
273
|
+
| inactive-color | 未选中标签的颜色 | _string_ | `#7d7e80` |
|
|
274
|
+
| placeholder | 固定在底部时,是否在标签位置生成一个等高的占位元素 | _boolean_ | `false` |
|
|
275
|
+
| safe-area-inset-bottom | 是否为 iPhoneX 留出底部安全距离 | _boolean_ | `true` |
|
|
276
|
+
| z-index | 元素 z-index | _number_ | `1` |
|
|
277
|
+
| upside-down `v2.5.1` | 上下颠倒 | _boolean_ | `false` |
|
|
278
|
+
|
|
279
|
+
### Tabbar Slot
|
|
280
|
+
|
|
281
|
+
| 名称 | 说明 |
|
|
282
|
+
| -------------- | ----------------------- |
|
|
283
|
+
| - | 默认插槽,插入子 tab 页 |
|
|
284
|
+
| left `v2.2.0` | tab 左侧的插槽 |
|
|
285
|
+
| right `v2.2.0` | tab 右侧的插槽 |
|
|
286
|
+
|
|
287
|
+
### Tabbar Event
|
|
288
|
+
|
|
289
|
+
| 事件名 | 说明 | 参数 |
|
|
290
|
+
| ----------- | -------------- | ---------------------------------------- |
|
|
291
|
+
| bind:change | 切换标签时触发 | event.detail: 当前选中标签的名称或索引值 |
|
|
292
|
+
|
|
293
|
+
### TabbarItem Props
|
|
294
|
+
|
|
295
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
296
|
+
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ---------------- |
|
|
297
|
+
| dot | 是否显示小红点 | _boolean_ | - |
|
|
298
|
+
| icon | 图标 svg 值或图片链接,可选值见 [Icon 组件](/material/smartui?comId=icon&appType=miniapp) | _string_ | - |
|
|
299
|
+
| icon-prefix | 图标类名前缀,同 Icon 组件的 [class-prefix 属性](/material/smartui?comId=icon&appType=miniapp#Props) | _string_ | `smart-icon` |
|
|
300
|
+
| info | 图标右上角提示信息 | _string \| number_ | - |
|
|
301
|
+
| link-type `v1.10.13` | 链接跳转类型,可选值为 `redirectTo`、[`switchTab`](https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.switchTab.html)、`reLaunch` | _string_ | `redirectTo` |
|
|
302
|
+
| name | 标签名称,作为匹配的标识符 | _string \| number_ | 当前标签的索引值 |
|
|
303
|
+
| url `v1.10.13` | 点击后跳转的链接地址, 需要以 `/` 开头 | _string_ | - |
|
|
304
|
+
| disabled `v2.3.5` | 是否禁用 | _boolean_ | - |
|
|
305
|
+
|
|
306
|
+
### TabbarItem Slot
|
|
307
|
+
|
|
308
|
+
| 名称 | 说明 |
|
|
309
|
+
| ----------- | -------------- |
|
|
310
|
+
| icon | 未选中时的图标 |
|
|
311
|
+
| icon-active | 选中时的图标 |
|
|
312
|
+
|
|
313
|
+
### TabbarItem Event
|
|
314
|
+
|
|
315
|
+
| 名称 | 说明 |
|
|
316
|
+
| ----- | ------------------------------------ |
|
|
317
|
+
| click | 点击事件,设置 disabled 时也会有回调 |
|
|
318
|
+
|
|
319
|
+
### 样式变量
|
|
320
|
+
|
|
321
|
+
组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](/material/smartui?comId=config-provider&appType=miniapp)。
|
|
322
|
+
|
|
323
|
+
| 名称 | 默认值 | 描述 |
|
|
324
|
+
| --------------------------- | -------------------------------------- | ---------------- |
|
|
325
|
+
| --tabbar-height | _55px_ | 标签栏高度 |
|
|
326
|
+
| --tabbar-background-color | _var(--app-B5, #f6f7fb)_ | 标签栏背景颜色 |
|
|
327
|
+
| --tabbar-border-color | _var(--app-B6-N7, rgba(0, 0, 0, 0.1))_ | 标签栏边框颜色 |
|
|
328
|
+
| --tabbar-item-font-size | _12px_ | 标签项字体大小 |
|
|
329
|
+
| --tabbar-item-text-color | _var(--app-B6-N5, rgba(0, 0, 0, 0.3))_ | 标签项文本颜色 |
|
|
330
|
+
| --tabbar-item-active-color | _var(--app-M1, #3678e3)_ | 活动状态项目颜色 |
|
|
331
|
+
| --tabbar-item-line-height | _1_ | 标签项行高 |
|
|
332
|
+
| --tabbar-item-icon-size | _22px_ | 标签项图标大小 |
|
|
333
|
+
| --tabbar-item-margin-bottom | _4px_ | 标签项下边距 |
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: 展示
|
|
3
|
+
new: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Tag 标签
|
|
7
|
+
|
|
8
|
+
> v2.0.0 开始加入
|
|
9
|
+
|
|
10
|
+
### 介绍
|
|
11
|
+
|
|
12
|
+
用于标记关键词和概括主要内容。
|
|
13
|
+
|
|
14
|
+
### 引入
|
|
15
|
+
|
|
16
|
+
在`app.json`或`index.json`中引入组件,详细介绍见[快速上手](/material/smartui?comId=help-getting-started&appType=miniapp)。
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
"usingComponents": {
|
|
20
|
+
"smart-tag": "@tuya-miniapp/smart-ui/lib/tag/index"
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 代码演示
|
|
25
|
+
|
|
26
|
+
### 基础用法
|
|
27
|
+
|
|
28
|
+
通过 `type` 属性控制标签颜色,默认为灰色。
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<smart-tag type="primary">标签</smart-tag>
|
|
32
|
+
<smart-tag type="success">标签</smart-tag>
|
|
33
|
+
<smart-tag type="danger">标签</smart-tag>
|
|
34
|
+
<smart-tag type="warning">标签</smart-tag>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 空心样式
|
|
38
|
+
|
|
39
|
+
设置 `plain` 属性设置为空心样式。
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<smart-tag plain type="primary">标签</smart-tag>
|
|
43
|
+
<smart-tag plain type="success">标签</smart-tag>
|
|
44
|
+
<smart-tag plain type="danger">标签</smart-tag>
|
|
45
|
+
<smart-tag plain type="warning">标签</smart-tag>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 圆角样式
|
|
49
|
+
|
|
50
|
+
通过 `round` 设置为圆角样式。
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<smart-tag round type="primary">标签</smart-tag>
|
|
54
|
+
<smart-tag round type="success">标签</smart-tag>
|
|
55
|
+
<smart-tag round type="danger">标签</smart-tag>
|
|
56
|
+
<smart-tag round type="warning">标签</smart-tag>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 标记样式
|
|
60
|
+
|
|
61
|
+
通过 `mark` 设置为标记样式(半圆角)。
|
|
62
|
+
|
|
63
|
+
```html
|
|
64
|
+
<smart-tag mark type="primary">标签</smart-tag>
|
|
65
|
+
<smart-tag mark type="success">标签</smart-tag>
|
|
66
|
+
<smart-tag mark type="danger">标签</smart-tag>
|
|
67
|
+
<smart-tag mark type="warning">标签</smart-tag>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 自定义颜色
|
|
71
|
+
```html
|
|
72
|
+
<smart-tag color="rgba(16, 208, 208, 1)">标签</smart-tag>
|
|
73
|
+
<smart-tag color="rgba(16, 208, 208, 0.2)" text-color="rgba(16, 208, 208, 1)">标签</smart-tag>
|
|
74
|
+
<smart-tag color="rgba(16, 208, 208, 1)" plain>标签</smart-tag>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 标签大小
|
|
78
|
+
|
|
79
|
+
```html
|
|
80
|
+
<smart-tag type="danger">标签</smart-tag>
|
|
81
|
+
<smart-tag type="danger" size="medium">标签</smart-tag>
|
|
82
|
+
<smart-tag type="danger" size="large">标签</smart-tag>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 可关闭标签
|
|
86
|
+
|
|
87
|
+
添加 `closeable` 属性表示标签是可关闭的,关闭标签时会触发 `close` 事件,在 `close` 事件中可以执行隐藏标签的逻辑。
|
|
88
|
+
|
|
89
|
+
```html
|
|
90
|
+
<smart-tag
|
|
91
|
+
ty:if="{{ show.primary }}"
|
|
92
|
+
closeable
|
|
93
|
+
size="medium"
|
|
94
|
+
type="primary"
|
|
95
|
+
id="primary"
|
|
96
|
+
bind:close="onClose"
|
|
97
|
+
>
|
|
98
|
+
标签
|
|
99
|
+
</smart-tag>
|
|
100
|
+
<smart-tag
|
|
101
|
+
ty:if="{{ show.success }}"
|
|
102
|
+
closeable
|
|
103
|
+
size="medium"
|
|
104
|
+
type="success"
|
|
105
|
+
id="success"
|
|
106
|
+
bind:close="onClose"
|
|
107
|
+
>
|
|
108
|
+
标签
|
|
109
|
+
</smart-tag>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
Page({
|
|
114
|
+
data: {
|
|
115
|
+
show: {
|
|
116
|
+
primary: true,
|
|
117
|
+
success: true,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
onClose(event) {
|
|
121
|
+
this.setData({
|
|
122
|
+
[`show.${event.target.id}`]: false,
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## API
|
|
129
|
+
|
|
130
|
+
### Props
|
|
131
|
+
|
|
132
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
133
|
+
| ---------- | ----------------------------------------------------- | --------- | ------- |
|
|
134
|
+
| close-icon-aria-label `v2.13.0` | 关闭按钮的无障碍读屏文案,透传至关闭图标的 `ariaLabel` | _string_ | - |
|
|
135
|
+
| closeable | 是否为可关闭标签 | _boolean_ | `false` |
|
|
136
|
+
| color | 标签颜色 | _string_ | - |
|
|
137
|
+
| mark | 是否为标记样式 | _boolean_ | `false` |
|
|
138
|
+
| plain | 是否为空心样式 | _boolean_ | `false` |
|
|
139
|
+
| round | 是否为圆角样式 | _boolean_ | `false` |
|
|
140
|
+
| size | 大小, 可选值为 `large` `medium` | _string_ | - |
|
|
141
|
+
| text-color | 文本颜色,优先级高于 `color` 属性 | _string_ | `white` |
|
|
142
|
+
| type | 类型,可选值为 `primary` `success` `danger` `warning` | _string_ | - |
|
|
143
|
+
|
|
144
|
+
### Slot
|
|
145
|
+
|
|
146
|
+
| 名称 | 说明 |
|
|
147
|
+
| ---- | ------------------- |
|
|
148
|
+
| - | 自定义 Tag 显示内容 |
|
|
149
|
+
|
|
150
|
+
### Events
|
|
151
|
+
|
|
152
|
+
| 事件名 | 说明 | 回调参数 |
|
|
153
|
+
| ---------- | -------------- | -------- |
|
|
154
|
+
| bind:close | 关闭标签时触发 | - |
|
|
155
|
+
|
|
156
|
+
### 外部样式类
|
|
157
|
+
|
|
158
|
+
| 类名 | 说明 |
|
|
159
|
+
| ------------ | ------------ |
|
|
160
|
+
| custom-class | 根节点样式类 |
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
### 样式变量
|
|
164
|
+
|
|
165
|
+
组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](/material/smartui?comId=config-provider&appType=miniapp)。
|
|
166
|
+
|
|
167
|
+
| 名称 | 默认值 | 描述 |
|
|
168
|
+
| ----------------------------- | -------------------------------------- | ---- |
|
|
169
|
+
| --tag-padding | _2px 8px_ | 组件padding |
|
|
170
|
+
| --tag-text-color | _#fff_ | 文字颜色 |
|
|
171
|
+
| --tag-border-radius | _4px_ | 组件外部radius |
|
|
172
|
+
| --tag-line-height | _17px_ | 文字默认行高 |
|
|
173
|
+
| --tag-medium-line-height | _20px_ | medium尺寸文字行高 |
|
|
174
|
+
| --tag-large-line-height | _22px_ | large尺寸文字行高 |
|
|
175
|
+
| --tag-font-size | _12px_ | 字体默认大小 |
|
|
176
|
+
| --tag-medium-font-size | _14px_ | medium尺寸字体大小 |
|
|
177
|
+
| --tag-large-font-size | _16px_ | large尺寸字体大小 |
|
|
178
|
+
| --tag-round-border-radius | _999px_ | round模式组件外部radius |
|
|
179
|
+
| --tag-default-color | _#969799_ | default模式背景色或边框色 |
|
|
180
|
+
| --tag-danger-color | _#ee0a24_ | danger模式背景色或边框色 |
|
|
181
|
+
| --tag-primary-color | _#1989fa_ | primary模式背景色或边框色 |
|
|
182
|
+
| --tag-success-color | _#07c160_ | success模式背景色或边框色 |
|
|
183
|
+
| --tag-warning-color | _#ff976a_ | warning模式背景色或边框色 |
|
|
184
|
+
| --tag-plain-background-color | _transparent_ | 空心模式背景色 |
|