Skeleton 骨架屏
骨架屏一般用于页面在请求远程数据尚未完成时,页面用灰色块预显示本来的页面结构,给用户更好的体验。
平台
| App | 小程序 | H5 |
|---|---|---|
| √ | √ | √ |
属性
| 属性名 | 类型 | 默认值 | 说明 | 平台 |
|---|---|---|---|---|
| rows | Array | [] | 行配置,数据格式见下方 | All |
| rowWidth | String,Number | 750rpx | 行宽 | All |
| rowHeight | String,Number | 36rpx | 行高 | All |
| rowMargin | String,Number,Array | 20rpx 0 0 | 边距 | All |
| color | String | #eee | 颜色 有children时不显示 | All |
| forceColor | String | 强制设置颜色 | All | |
| radius | String,Number,Array | 6rpx | 圆角 | All |
| animate | Boolean | true | 开启动画 | All |
| cClass | String,Array,Object | null | 组件类 | All |
| cStyle | String,Array,Object | null | 组件样式 | All |
| margin | String,Number,Array | null | 外边距 | All |
| padding | String,Number,Array | null | 内边距 | All |
| bgColor | String | null | 背景色,支持c-bg-开头的背景色类 | All |
rows属性的数据格式:
[
{
width:'宽',
height:'高', // children不为空时此设置无效
margin:'边距', // 边距支持'x','tb lr','t lr b','t r b l'对应的数组写法。
fill:'flex填充', // flex填充,值为数字
radius:'圆角', // 圆角,值round表示圆形,支持c-radius-开头的类,支持'x','tb lr','t lr b','t r b l'对应的数组写法。
color:'颜色', // 如果拥有子项,将不生效,使用默认颜色。
forceColor:'强制设置color颜色,用于拥有子项父级元素设置背景色',
row:true, // 开启横向布局
align:'行方向,列方向', 行方向值:left,center,right,between,around,列方向值:top,center,bottom
text:'显示的文本' // string或Object
children:[] // 子级
},
0, // 数字表示重复第0个索引项
// ...
]1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| 插槽名 | 说明 |
|---|---|
| before | - |
| default | - |
示例
vue
<template>
<c-skeleton :rows="[
{height:94,margin:'8 15 8',radius:'c-radius-base'},0,0
]" />
</template>1
2
3
4
5
2
3
4
5
