11<frame />
22
33# Skeleton 骨架屏
4+
45用于等待加载内容所展示的占位图形组合,有动态效果加载效果,减少用户等待焦虑。
56
67## 骨架图风格
8+
79支持 ` avatar ` 、` image ` 、` text ` 、` paragraph ` 四种类型。
10+
811``` html
912// 头像骨架屏
1013<wd-skeleton theme =" avatar" />
1417<wd-skeleton theme =" text" />
1518// 段落骨架屏
1619<wd-skeleton theme =" paragraph" />
20+
1721```
22+
1823## 宫格骨架屏
24+
1925``` html
2026<wd-skeleton :row-col =" grid" />
2127```
28+
2229``` ts
2330const grid = [
2431 [
@@ -38,8 +45,8 @@ const grid = [
3845]
3946```
4047
41-
4248## 单元格骨架屏
49+
4350``` html
4451<view style =" display : flex " >
4552 <wd-skeleton :row-col =" [{ size: '48px', type: 'circle' }]" />
@@ -52,12 +59,14 @@ const grid = [
5259```
5360
5461## 图片组合骨架屏
62+
5563``` html
5664<view >
5765 <wd-skeleton :row-col =" imageGroup" />
5866 <wd-skeleton :custom-style =" { marginTop: '20px' }" :row-col =" imageGroup" />
5967</view >
6068```
69+
6170``` ts
6271const imageGroup = [
6372 { height: ' 171px' }, 1 , { width: ' 107px' },
@@ -66,7 +75,9 @@ const imageGroup = [
6675```
6776
6877## 加载动画
78+
6979支持 ` gradient ` 、` flashed `
80+
7081``` html
7182<wd-skeleton animation =" gradient" theme =" paragraph" />
7283<view style =" display : flex " >
@@ -75,10 +86,55 @@ const imageGroup = [
7586</view >
7687```
7788
89+ ## 插槽内容
90+
91+ 可以通过插槽写入展示的内容,当请求结束,将loading设置为false,此时会隐藏骨架组件,同时展示插槽内容。
92+
93+ ``` html
94+ <wd-skeleton
95+ :row-col =" [
96+ [
97+ { width: '48px', height: '48px' },
98+ { width: '48px', height: '48px' },
99+ { width: '48px', height: '48px' },
100+ { width: '48px', height: '48px' },
101+ { width: '48px', height: '48px' }
102+ ],
103+ [
104+ { width: '48px', height: '16px' },
105+ { width: '48px', height: '16px' },
106+ { width: '48px', height: '16px' },
107+ { width: '48px', height: '16px' },
108+ { width: '48px', height: '16px' }
109+ ]
110+ ]"
111+ :loading =" showContent"
112+ >
113+ <wd-grid >
114+ <wd-grid-item icon-size =" 32px" icon =" picture" text =" 文字" />
115+ <wd-grid-item icon-size =" 32px" icon =" picture" text =" 文字" />
116+ <wd-grid-item icon-size =" 32px" icon =" picture" text =" 文字" />
117+ <wd-grid-item icon-size =" 32px" icon =" picture" text =" 文字" />
118+ <wd-grid-item icon-size =" 32px" icon =" picture" text =" 文字" />
119+ </wd-grid >
120+ </wd-skeleton >
121+ ```
122+
123+ ``` js
124+ const showContent = ref (true )
125+ ```
126+
78127## Attributes
79- | 参数 | 说明 | 类型 | 可选值 | 默认值 | 最低版本 |
80- | ------------ | ----------------------------------------------------------------| ------- | ------------------------- | ------------ | -------- |
81- | theme | 骨架图风格 | SkeletonTheme | ` text ` ` avatar ` ` paragraph ` ` image ` | - | - |
82- | rowCol | 用于设置行列数量、宽度高度、间距等<br />【示例一】` [1, 1, 2] ` 表示输出三行骨架图,第一行一列,第二行一列,第三行两列。 <br />【示例二】` [1, 1, { width: '100px' }] ` 表示自定义第三行的宽度为 ` 100px ` 。 <br />【示例三】` [1, 2, [{ width, height }, { width, height, marginLeft }]] ` 表示第三行有两列,且自定义宽度、高度和间距 | SkeletonRowCol | - | - | - |
83- | loading | 是否为加载状态,如果是则显示骨架图,如果不是则显示加载完成的内容 | boolean | - | true | - |
84- | animation | 动画效果 | SkeletonAnimation | ` gradient ` ` flashed ` | - | - |
128+
129+ | 参数 | 说明 | 类型 | 可选值 | 默认值 | 最低版本 |
130+ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------- | ----------------------------------- | ------ | -------- |
131+ | theme | 骨架图风格 | SkeletonTheme | ` text ` ` avatar ` ` paragraph ` ` image ` | - | - |
132+ | rowCol | 用于设置行列数量、宽度高度、间距等<br />【示例一】` [1, 1, 2] ` 表示输出三行骨架图,第一行一列,第二行一列,第三行两列。 <br />【示例二】` [1, 1, { width: '100px' }] ` 表示自定义第三行的宽度为 ` 100px ` 。 <br />【示例三】` [1, 2, [{ width, height }, { width, height, marginLeft }]] ` 表示第三行有两列,且自定义宽度、高度和间距 | SkeletonRowCol | - | - | - |
133+ | loading | 是否为加载状态,如果是则显示骨架图,如果不是则显示加载完成的内容 | boolean | - | true | - |
134+ | animation | 动画效果 | SkeletonAnimation | ` gradient ` ` flashed ` | - | - |
135+
136+ ## Slots
137+
138+ | name | 说明 | 最低版本 |
139+ | ------- | --------------------- | ---------------- |
140+ | default | loading结束后展示内容 | $LOWEST_VERSION$ |
0 commit comments