@tuya-miniapp/smart-ui 2.13.2-beta-0 → 2.13.2-beta-2
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/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/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 +1 -1
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: 展示
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Icon 图标
|
|
6
|
+
|
|
7
|
+
### 介绍
|
|
8
|
+
|
|
9
|
+
基于字体的图标集,可以通过 Icon 组件使用,也可以在其他组件中通过 icon 属性引用。
|
|
10
|
+
|
|
11
|
+
### 引入
|
|
12
|
+
|
|
13
|
+
在`app.json`或`index.json`中引入组件,详细介绍见[快速上手](/material/smartui?comId=help-getting-started&appType=miniapp)。
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
"usingComponents": {
|
|
17
|
+
"smart-icon": "@tuya-miniapp/smart-ui/lib/icon/index"
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
在`index.ts`中引入 icon svg
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import warningIcon from '@tuya-miniapp/icons/dist/svg/Warning';
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 代码演示
|
|
28
|
+
|
|
29
|
+
### 基础用法
|
|
30
|
+
|
|
31
|
+
`Icon`的`name`属性支持传入图标名称或图片链接。
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<smart-icon name="{{ warningIcon }}" />
|
|
35
|
+
<smart-icon name="https://static1.tuyacn.com/static/tuya-miniapp-doc/_next/static/images/logo-small.png" />
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 提示信息
|
|
39
|
+
|
|
40
|
+
设置`dot`属性后,会在图标右上角展示一个小红点。设置`info`属性后,会在图标右上角展示相应的徽标。
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<smart-icon name="{{ warningIcon }}" dot />
|
|
44
|
+
<smart-icon name="{{ warningIcon }}" info="9" />
|
|
45
|
+
<smart-icon name="{{ warningIcon }}" info="99+" />
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 图标颜色
|
|
49
|
+
|
|
50
|
+
设置`color`属性来控制图标颜色。
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<smart-icon name="{{ warningIcon }}" color="red" />
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 图标大小
|
|
57
|
+
|
|
58
|
+
设置`size`属性来控制图标大小。
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<smart-icon name="{{ warningIcon }}" size="50px" />
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 自定义图标
|
|
65
|
+
|
|
66
|
+
如果需要在现有 Icon 的基础上使用更多图标,可以引入第三方 iconfont 对应的字体文件和 CSS 文件,之后就可以在 Icon 组件中直接使用。例如,可以在 `app.wxss` 文件中引入。
|
|
67
|
+
|
|
68
|
+
```css
|
|
69
|
+
/* 引入第三方或自定义的字体图标样式 */
|
|
70
|
+
@font-face {
|
|
71
|
+
font-family: 'my-icon';
|
|
72
|
+
src: url('./my-icon.ttf') format('truetype');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.my-icon {
|
|
76
|
+
font-family: 'my-icon';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.my-icon-extra::before {
|
|
80
|
+
content: '\e626';
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```html
|
|
85
|
+
<!-- 通过 class-prefix 指定类名为 my-icon -->
|
|
86
|
+
<smart-icon class-prefix="my-icon" name="extra" />
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Svg Path `v2.3.3`
|
|
90
|
+
|
|
91
|
+
组件现在也支持传入path的方式渲染
|
|
92
|
+
```html
|
|
93
|
+
<smart-icon
|
|
94
|
+
name="M192 448C192 624.736 335.264 768 512 768s320-143.264 320-320a319.872 319.872 0 0 0-160-277.184V160a64 64 0 0 0-64-64h-192a64 64 0 0 0-64 64v10.816A319.872 319.872 0 0 0 192 448z m224-384h192a32 32 0 0 0 0-64h-192a32 32 0 0 0 0 64z"
|
|
95
|
+
size="36"
|
|
96
|
+
color="#1989fa"
|
|
97
|
+
/>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
## API
|
|
102
|
+
|
|
103
|
+
### Props
|
|
104
|
+
|
|
105
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
106
|
+
| ------------ | ------------------------------------------ | ------------------ | ------------ |
|
|
107
|
+
| aria-label `v2.13.0` | 无障碍读屏文案;非空时根节点 `aria-role` 为 `button` | _string_ | - |
|
|
108
|
+
| aria-role `v2.13.0` | 无障碍 `aria-role` | _string_ | - |
|
|
109
|
+
| class-prefix | 类名前缀 | _string_ | `smart-icon` |
|
|
110
|
+
| color | 图标颜色 | _string_ | `inherit` |
|
|
111
|
+
| custom-style | 自定义样式 | _string_ | - |
|
|
112
|
+
| dot | 是否显示图标右上角小红点 | _boolean_ | `false` |
|
|
113
|
+
| info | 图标右上角文字提示 | _string \| number_ | - |
|
|
114
|
+
| name | 图标名称或 Svg URL 或图片链接 | _string_ | - |
|
|
115
|
+
| size | 图标大小,如 `20px`,`2em`,默认单位为`px` | _string \| number_ | `inherit` |
|
|
116
|
+
|
|
117
|
+
### Events
|
|
118
|
+
|
|
119
|
+
| 事件名 | 说明 | 参数 |
|
|
120
|
+
| ---------- | -------------- | ---- |
|
|
121
|
+
| bind:click | 点击图标时触发 | - |
|
|
122
|
+
|
|
123
|
+
### 外部样式类
|
|
124
|
+
|
|
125
|
+
| 类名 | 说明 |
|
|
126
|
+
| ------------ | -------------------- |
|
|
127
|
+
| custom-class | 根节点样式类 |
|
|
128
|
+
| info-class | 图标右上角文字样式类 |
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
### 样式变量
|
|
132
|
+
|
|
133
|
+
组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](/material/smartui?comId=config-provider&appType=miniapp)。
|
|
134
|
+
|
|
135
|
+
| 名称 | 默认值 | 描述 |
|
|
136
|
+
| ----------------------------- | -------------------------------------- | ---- |
|
|
137
|
+
| --icon-color | _var(--app-B4-N2, rgba(0, 0, 0, 0.7))_ | 图标颜色 |
|
|
138
|
+
|
|
139
|
+
## 常见问题
|
|
140
|
+
|
|
141
|
+
### 开发者工具上提示 Failed to load font 是什么情况?
|
|
142
|
+
|
|
143
|
+
这个是开发者工具本身的问题,可以忽略,具体可以查看[微信小程序文档](https://developers.weixin.qq.com/miniprogram/dev/api/ui/font/wx.loadFontFace.html) - 注意事项第 5 条。
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: 展示
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Image 图片
|
|
6
|
+
|
|
7
|
+
### 介绍
|
|
8
|
+
|
|
9
|
+
增强版的 img 标签,提供多种图片填充模式,支持图片懒加载、加载中提示、加载失败提示。
|
|
10
|
+
|
|
11
|
+
### 引入
|
|
12
|
+
|
|
13
|
+
在`app.json`或`index.json`中引入组件,详细介绍见[快速上手](/material/smartui?comId=help-getting-started&appType=miniapp)。
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
"usingComponents": {
|
|
17
|
+
"smart-image": "@tuya-miniapp/smart-ui/lib/image/index"
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 代码演示
|
|
22
|
+
|
|
23
|
+
### 基础用法
|
|
24
|
+
|
|
25
|
+
基础用法与原生 [image](<(https://developers.weixin.qq.com/miniprogram/dev/component/image.html)>) 标签一致,可以设置`src`、`width`、`height`等原生属性。
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<smart-image width="100" height="100" src="https://static1.tuyacn.com/static/tuya-miniapp-doc/_next/static/images/logo-small.png" />
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 填充模式
|
|
32
|
+
|
|
33
|
+
通过`fit`属性可以设置图片填充模式,可选值见下方表格。
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<smart-image
|
|
37
|
+
width="10rem"
|
|
38
|
+
height="10rem"
|
|
39
|
+
fit="contain"
|
|
40
|
+
src="https://static1.tuyacn.com/static/tuya-miniapp-doc/_next/static/images/logo-small.png"
|
|
41
|
+
/>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 圆形图片
|
|
45
|
+
|
|
46
|
+
通过`round`属性可以设置图片变圆,注意当图片宽高不相等且`fit`为`contain`或`scale-down`时,将无法填充一个完整的圆形。
|
|
47
|
+
|
|
48
|
+
```html
|
|
49
|
+
<smart-image
|
|
50
|
+
round
|
|
51
|
+
width="10rem"
|
|
52
|
+
height="10rem"
|
|
53
|
+
src="https://static1.tuyacn.com/static/tuya-miniapp-doc/_next/static/images/logo-small.png"
|
|
54
|
+
/>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 图片懒加载
|
|
58
|
+
|
|
59
|
+
图片懒加载,在即将进入一定范围(上下三屏)时才开始加载。
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<smart-image
|
|
63
|
+
width="100"
|
|
64
|
+
height="100"
|
|
65
|
+
lazy-load
|
|
66
|
+
src="https://static1.tuyacn.com/static/tuya-miniapp-doc/_next/static/images/logo-small.png"
|
|
67
|
+
/>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 加载中提示
|
|
71
|
+
|
|
72
|
+
`Image`组件提供了默认的加载中提示,支持通过`loading`插槽自定义内容。
|
|
73
|
+
|
|
74
|
+
```html
|
|
75
|
+
<smart-image show-loading use-loading-slot>
|
|
76
|
+
<smart-loading slot="loading" type="spinner" size="20" vertical />
|
|
77
|
+
</smart-image>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 加载失败提示
|
|
81
|
+
|
|
82
|
+
`Image`组件提供了默认的加载失败提示,支持通过`error`插槽自定义内容。
|
|
83
|
+
|
|
84
|
+
```html
|
|
85
|
+
<smart-image use-error-slot>
|
|
86
|
+
<text slot="error">加载失败</text>
|
|
87
|
+
</smart-image>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 修改图片颜色 `v2.3.3`
|
|
91
|
+
|
|
92
|
+
`tint-color`属性可以直接修改图片的颜色,类似RN的tintColor属性,原理是通过css mask实现的,所以使用之前要做好用户兼容性调查哦。
|
|
93
|
+
|
|
94
|
+
```html
|
|
95
|
+
<smart-image
|
|
96
|
+
width="100"
|
|
97
|
+
height="100"
|
|
98
|
+
src="https://static1.tuyacn.com/static/tuya-miniapp-doc/_next/static/images/logo-small.png"
|
|
99
|
+
tint-color="rgba(255, 255, 25, 0.4)"
|
|
100
|
+
/>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## API
|
|
104
|
+
|
|
105
|
+
### Props
|
|
106
|
+
|
|
107
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
108
|
+
| ---------------------- | ------------------------------------ | ------------------ | ------- |
|
|
109
|
+
| alt | 替代文本 | _string_ | - |
|
|
110
|
+
| fit | 图片填充模式 | _string_ | _fill_ |
|
|
111
|
+
| height | 高度,默认单位为`px` | _string \| number_ | - |
|
|
112
|
+
| lazy-load | 是否懒加载 | _boolean_ | `false` |
|
|
113
|
+
| radius | 圆角大小,默认单位为`px` | _string \| number_ | `0` |
|
|
114
|
+
| round | 是否显示为圆形 | _boolean_ | `false` |
|
|
115
|
+
| show-error | 是否展示图片加载失败提示 | _boolean_ | `true` |
|
|
116
|
+
| show-loading | 是否展示图片加载中提示 | _boolean_ | `true` `v2.0.0` `false` `v2.7.0` |
|
|
117
|
+
| show-menu-by-longpress | 是否开启长按图片显示识别小程序码菜单 | _boolean_ | `false` |
|
|
118
|
+
| src | 图片链接 | _string_ | - |
|
|
119
|
+
| use-error-slot | 是否使用 error 插槽 | _boolean_ | `false` |
|
|
120
|
+
| use-loading-slot | 是否使用 loading 插槽 | _boolean_ | `false` |
|
|
121
|
+
| webp `v1.10.11` | 是否解析 webp 格式 | _boolean_ | `false` |
|
|
122
|
+
| width | 宽度,默认单位为`px` | _string \| number_ | - |
|
|
123
|
+
| tint-color `v2.3.3` | 修改图片颜色,类似RN的tintColor,采用css mask实现 | _string_ | - |
|
|
124
|
+
|
|
125
|
+
### 图片填充模式
|
|
126
|
+
|
|
127
|
+
| 名称 | 含义 |
|
|
128
|
+
| --------- | ------------------------------------------------------ |
|
|
129
|
+
| contain | 保持宽高缩放图片,使图片的长边能完全显示出来 |
|
|
130
|
+
| cover | 保持宽高缩放图片,使图片的短边能完全显示出来,裁剪长边 |
|
|
131
|
+
| fill | 拉伸图片,使图片填满元素 |
|
|
132
|
+
| heightFix | 缩放模式,高度不变,宽度自动变化,保持原图宽高比不变 |
|
|
133
|
+
| none | 保持图片原有尺寸 |
|
|
134
|
+
| widthFix | 缩放模式,宽度不变,高度自动变化,保持原图宽高比不变 |
|
|
135
|
+
|
|
136
|
+
### Events
|
|
137
|
+
|
|
138
|
+
| 事件名 | 说明 | 回调参数 |
|
|
139
|
+
| ---------- | ------------------ | ------------ |
|
|
140
|
+
| bind:click | 点击图片时触发 | event: Event |
|
|
141
|
+
| bind:error | 图片加载失败时触发 | event: Event |
|
|
142
|
+
| bind:load | 图片加载完毕时触发 | event: Event |
|
|
143
|
+
|
|
144
|
+
### Slots
|
|
145
|
+
|
|
146
|
+
| 名称 | 说明 |
|
|
147
|
+
| ------- | -------------------------- |
|
|
148
|
+
| error | 自定义加载失败时的提示内容 |
|
|
149
|
+
| loading | 自定义加载中的提示内容 |
|
|
150
|
+
|
|
151
|
+
### 外部样式类
|
|
152
|
+
|
|
153
|
+
| 类名 | 说明 |
|
|
154
|
+
| ------------- | -------------- |
|
|
155
|
+
| custom-class | 根节点样式类 |
|
|
156
|
+
| error-class | error 样式类 |
|
|
157
|
+
| image-class | 图片样式类 |
|
|
158
|
+
| loading-class | loading 样式类 |
|
|
159
|
+
|
|
160
|
+
### 样式变量
|
|
161
|
+
|
|
162
|
+
组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](/material/smartui?comId=config-provider&appType=miniapp)。
|
|
163
|
+
|
|
164
|
+
| 名称 | 默认值 | 描述 |
|
|
165
|
+
| ----------------------------- | -------------------------------------- | ---- |
|
|
166
|
+
| --image-placeholder-text-color | _#969799_ | 加载描述文字 |
|
|
167
|
+
| --image-placeholder-font-size | _14px_ | 加载文字字体 |
|
|
168
|
+
| --image-placeholder-background-color | _#f7f8fa_ | 加载遮照背景色 |
|
|
169
|
+
| --image-loading-icon-size | _32px_ | 加载图标体积 |
|
|
170
|
+
| --image-loading-icon-color | _#dcdee0_ | 加载图标颜色 |
|
|
171
|
+
| --image-error-size `v2.0.0` | _32px_ | 图片加载错误时默认图片 |
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: 导航
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# IndexBar 索引栏
|
|
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-index-bar": "@tuya-miniapp/smart-ui/lib/index-bar/index",
|
|
18
|
+
"smart-index-anchor": "@tuya-miniapp/smart-ui/lib/index-anchor/index"
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```warning:⚠️注意
|
|
23
|
+
组件是监听整个page 滚动事件来做动态的 fixed 标题元素,所以渲染此组件的页面必须配置 页面可滚动。
|
|
24
|
+
|
|
25
|
+
index.config.ts:
|
|
26
|
+
|
|
27
|
+
export default {
|
|
28
|
+
navigationBarTitleText: 'Home',
|
|
29
|
+
disableScroll: false,
|
|
30
|
+
};
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 代码演示
|
|
34
|
+
|
|
35
|
+
### 基础用法
|
|
36
|
+
|
|
37
|
+
点击索引栏时,会自动跳转到对应的`IndexAnchor`锚点位置。设置 `scrollable` 后可滑动定位;设置 `show-move-tip`(`v2.12.0`)可在拖动侧边栏时显示跟随手指的提示气泡。
|
|
38
|
+
|
|
39
|
+
```html
|
|
40
|
+
<smart-index-bar scrollable show-move-tip>
|
|
41
|
+
<view wx:for="{{ indexList }}" wx:for-item="item" wx:key="item">
|
|
42
|
+
<smart-index-anchor index="{{ item }}" />
|
|
43
|
+
<smart-cell title="文本" />
|
|
44
|
+
<smart-cell title="文本" />
|
|
45
|
+
<smart-cell title="文本" />
|
|
46
|
+
</view>
|
|
47
|
+
</smart-index-bar>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
const indexList = [];
|
|
52
|
+
const charCodeOfA = 'A'.charCodeAt(0);
|
|
53
|
+
|
|
54
|
+
for (let i = 0; i < 26; i++) {
|
|
55
|
+
indexList.push(String.fromCharCode(charCodeOfA + i));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
Page({
|
|
59
|
+
data: {
|
|
60
|
+
indexList, // A-Z 字母列表
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 自定义索引列表
|
|
66
|
+
|
|
67
|
+
可以通过`index-list`属性自定义展示的索引字符列表。
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<smart-index-bar index-list="{{ customIndexList }}">
|
|
71
|
+
<view wx:for="{{ customIndexList }}" wx:key="index">
|
|
72
|
+
<smart-index-anchor use-slot index="{{ item }}">
|
|
73
|
+
<text>标题{{ item }}</text>
|
|
74
|
+
</smart-index-anchor>
|
|
75
|
+
<smart-cell title="文本" />
|
|
76
|
+
<smart-cell title="文本" />
|
|
77
|
+
<smart-cell title="文本" />
|
|
78
|
+
</view>
|
|
79
|
+
</smart-index-bar>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```javascript
|
|
83
|
+
Page({
|
|
84
|
+
data: {
|
|
85
|
+
customIndexList: [1, 2, 3, 4, 5, 6, 8, 9, 10],
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 自定义侧边栏样式 `v2.11.0`
|
|
91
|
+
|
|
92
|
+
`sidebar-font-size` 和 `sidebar-line-height` 属性可以设置侧边栏的字体样式
|
|
93
|
+
|
|
94
|
+
```html
|
|
95
|
+
<smart-index-bar sidebar-font-size="16px" sidebar-line-height="20px">
|
|
96
|
+
<view wx:for="{{ indexList }}" wx:for-item="item" wx:key="item">
|
|
97
|
+
<smart-index-anchor index="{{ item }}" />
|
|
98
|
+
<smart-cell title="文本" />
|
|
99
|
+
<smart-cell title="文本" />
|
|
100
|
+
<smart-cell title="文本" />
|
|
101
|
+
</view>
|
|
102
|
+
</smart-index-bar>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
```javascript
|
|
106
|
+
const indexList = [];
|
|
107
|
+
const charCodeOfA = 'A'.charCodeAt(0);
|
|
108
|
+
|
|
109
|
+
for (let i = 0; i < 26; i++) {
|
|
110
|
+
indexList.push(String.fromCharCode(charCodeOfA + i));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
Page({
|
|
114
|
+
data: {
|
|
115
|
+
indexList, // A-Z 字母列表
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## API
|
|
121
|
+
|
|
122
|
+
### IndexBar Props
|
|
123
|
+
|
|
124
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
125
|
+
| ----------------------------- | -------------------------- | ---------------------- | --------- |
|
|
126
|
+
| highlight-color | 索引字符高亮颜色 | _string_ | `#07c160` |
|
|
127
|
+
| index-list | 索引字符列表 | _string[] \| number[]_ | `A-Z` |
|
|
128
|
+
| sticky | 是否开启锚点自动吸顶 | _boolean_ | `true` |
|
|
129
|
+
| sticky-push `v2.13.0` | 滚动时是否开启上一个吸顶锚点的上推动画效果 | _boolean_ | `true` |
|
|
130
|
+
| sticky-offset-top | 锚点自动吸顶时与顶部的距离 | _number_ | `0` |
|
|
131
|
+
| z-index | z-index 层级 | _number_ | `1` |
|
|
132
|
+
| scrollable `v2.1.7` | SideBar 是否可滚动定位 | _boolean_ | `false` |
|
|
133
|
+
| show-move-tip `v2.12.0` | 是否在拖动侧边栏时显示跟随手指的提示气泡 | _boolean_ | `false` |
|
|
134
|
+
| sidebar-font-size `v2.11.0` | SideBar 字体大小 | _string_ | - |
|
|
135
|
+
| sidebar-line-height `v2.11.0` | SideBar 字体行高 | _string_ | - |
|
|
136
|
+
|
|
137
|
+
### IndexAnchor Props
|
|
138
|
+
|
|
139
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
140
|
+
| -------- | ------------------------ | ------------------ | ------- |
|
|
141
|
+
| index | 索引字符 | _string \| number_ | - |
|
|
142
|
+
| use-slot | 是否使用自定义内容的插槽 | _boolean_ | `false` |
|
|
143
|
+
|
|
144
|
+
### IndexBar Events
|
|
145
|
+
|
|
146
|
+
| 事件名 | 说明 | 回调参数 |
|
|
147
|
+
| ------ | -------------- | --------------- |
|
|
148
|
+
| select | 选中字符时触发 | index: 索引字符 |
|
|
149
|
+
|
|
150
|
+
### IndexAnchor Slots
|
|
151
|
+
|
|
152
|
+
| 名称 | 说明 |
|
|
153
|
+
| ---- | -------------------------------- |
|
|
154
|
+
| - | 锚点位置显示内容,默认为索引字符 |
|
|
155
|
+
|
|
156
|
+
### 样式变量
|
|
157
|
+
|
|
158
|
+
组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](/material/smartui?comId=config-provider&appType=miniapp)。
|
|
159
|
+
|
|
160
|
+
**IndexBar**
|
|
161
|
+
|
|
162
|
+
| 名称 | 默认值 | 描述 |
|
|
163
|
+
| ----------------------------------------- | ------------ | ---------------------- |
|
|
164
|
+
| --index-bar-index-font-size | _10px_ | 侧边栏索引字体大小 |
|
|
165
|
+
| --index-bar-index-line-height | _14px_ `v2.0.0` _16px_ `v2.12.0` | 侧边栏索引行高 |
|
|
166
|
+
| --index-bar-move-tip-text-padding `v2.12.0` | _0 10px 0 0_ | 拖动提示文字内边距 |
|
|
167
|
+
| --index-bar-move-tip-text-font-size `v2.12.0` | _24px_ | 拖动提示文字字体大小 |
|
|
168
|
+
| --index-bar-move-tip-text-line-height `v2.12.0` | _32px_ | 拖动提示文字行高 |
|
|
169
|
+
| --index-bar-move-tip-text-color `v2.12.0` | _#fff_ | 拖动提示文字颜色 |
|
|
170
|
+
|
|
171
|
+
**IndexAnchor**
|
|
172
|
+
|
|
173
|
+
| 名称 | 默认值 | 描述 |
|
|
174
|
+
| --------------------------------------- | ------------- | ------------------ |
|
|
175
|
+
| --index-anchor-padding | _0 16px_ | 锚点内边距 |
|
|
176
|
+
| --index-anchor-text-color | _rgba(0,0,0,1)_ | 锚点文字颜色 |
|
|
177
|
+
| --index-anchor-font-weight | _500_ | 锚点字重 |
|
|
178
|
+
| --index-anchor-font-size | _14px_ | 锚点字体大小 |
|
|
179
|
+
| --index-anchor-line-height | _32px_ | 锚点行高 |
|
|
180
|
+
| --index-anchor-background-color | _transparent_ | 锚点背景色 |
|
|
181
|
+
| --index-anchor-active-background-color | _#ffffff_ | 锚点吸顶时背景色 |
|
|
182
|
+
| --index-anchor-active-text-color | _#3678e3_ | 锚点吸顶时文字颜色 |
|
|
183
|
+
| --index-anchor-index-padding | _0 4px 0 20px_ | 锚点右侧索引内边距 |
|
|
184
|
+
|
|
185
|
+
## 常见问题
|
|
186
|
+
|
|
187
|
+
### 嵌套在滚动元素中 IndexAnchor 失效?
|
|
188
|
+
|
|
189
|
+
由于 `<IndexBar />` 内部使用 ty.pageScrollTo 滚动到指定位置,因此只支持页面级滚动,无法在滚动元素中嵌套使用,例如:`view` 使用 `overflow: scroll;` 或者 `scroll-view`,具体可查看[微信小程序文档](https://developers.weixin.qq.com/miniprogram/dev/api/ui/scroll/ty.pageScrollTo.html)。
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: 展示
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Loading 加载
|
|
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-loading": "@tuya-miniapp/smart-ui/lib/loading/index"
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 代码演示
|
|
22
|
+
|
|
23
|
+
### 加载类型
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<smart-loading />
|
|
27
|
+
<smart-loading type="spinner" />
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 自定义颜色
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<smart-loading color="red" />
|
|
34
|
+
<smart-loading type="spinner" color="green" />
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 加载文案
|
|
38
|
+
|
|
39
|
+
```html
|
|
40
|
+
<smart-loading size="24px">加载中...</smart-loading>
|
|
41
|
+
<smart-loading color="var(--app-B1-N1)" icon-color="#1989FA" size="24px">加载中...</smart-loading>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 垂直排列
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<smart-loading size="24px" vertical>加载中...</smart-loading>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## API
|
|
51
|
+
|
|
52
|
+
### Props
|
|
53
|
+
|
|
54
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
55
|
+
| ------------------ | ----------------------------- | ------------------ | ---------- |
|
|
56
|
+
| color | 整体颜色 | _string_ | `var(--loading-text-color, #1989FA)` |
|
|
57
|
+
| size | 加载图标大小,默认单位为 `px` | _string \| number_ | `30px` |
|
|
58
|
+
| text-size `v1.0.0` | 文字大小,默认单位为为 `px` | _string \| number_ | `14px` |
|
|
59
|
+
| type | 类型,可选值为 `spinner` | _string_ | `circular` |
|
|
60
|
+
| vertical `v1.0.0` | 是否垂直排列图标和文字内容 | _boolean_ | `false` |
|
|
61
|
+
| icon-color `v2.8.0` | 单独控制icon的颜色 | _string_ | `var(--loading-spinner-color, #1989FA)` |
|
|
62
|
+
|
|
63
|
+
### Slots
|
|
64
|
+
|
|
65
|
+
| 名称 | 说明 |
|
|
66
|
+
| ---- | -------- |
|
|
67
|
+
| - | 加载文案 |
|
|
68
|
+
|
|
69
|
+
### 外部样式类
|
|
70
|
+
|
|
71
|
+
| 类名 | 说明 |
|
|
72
|
+
| ------------ | ------------ |
|
|
73
|
+
| custom-class | 根节点样式类 |
|
|
74
|
+
|
|
75
|
+
### 样式变量
|
|
76
|
+
|
|
77
|
+
组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](/material/smartui?comId=config-provider&appType=miniapp)。
|
|
78
|
+
|
|
79
|
+
| 名称 | 默认值 | 描述 |
|
|
80
|
+
| ----------------------------- | -------------------------------------- | ---- |
|
|
81
|
+
| --loading-text-color | _#969799_ | 文本颜色 |
|
|
82
|
+
| --loading-text-font-size | _14px_ | 文本字体大小 |
|
|
83
|
+
| --loading-text-line-height | _20px_ | 文本行高 |
|
|
84
|
+
| --loading-spinner-color | _#1989FA_ | 加载器颜色 |
|
|
85
|
+
| --loading-spinner-size | _30px_ | 加载器大小 |
|
|
86
|
+
| --loading-spinner-animation-duration | _0.8s_ | 加载动画持续时间 |
|