跳转到主内容
反馈类 · Skeleton
骨架屏
在需要等待加载内容的位置提供的占位组件。

概述 ​

  • Avatar:占位头像,默认为圆形,默认尺寸:Avatar medium: width: 48px,height: 48px。支持 Avatar 的 size、shape 属性 (v2.20后支持)
  • Image:占位图像,默认尺寸:width: 100%,height: 100%。
  • Title:占位标题,默认尺寸:width: 100%, height: 24px。
  • Paragraph:占位内容部分,默认尺寸:width: 100%,height: 16px,margin-bottom: 10px。
  • Button:占位按钮,默认尺寸:width: 115px,height: 32px。

注意:默认样式均可通过 className 或 style 进行自定义。

Vue 使用说明:从 @aifuxi/semi-ui-vue/skeleton 子路径引入组件,浏览器构建会自动按需加载默认主题。本页 Vue API 与示例以当前公开实现为准。

代码演示 ​

如何引入 ​

查看代码 · js
import { Skeleton } from '@aifuxi/semi-ui-vue';

基本使用 ​

显示加载内容




组合使用 ​

图片和标题。

统计数字。

头像和标题。

居中段落和按钮。

头像、标题和段落。

表格。

加载动画 ​

通过设置 active 属性可以展示动画效果。

API 参考 ​

Vue 契约 ​

以下内容以 packages/ui/src/skeleton/types.ts、packages/ui/src/skeleton/index.ts 的公开类型为准。

Vue 用法 ​

  • SkeletonButton、SkeletonImage、SkeletonTitle 只使用 SkeletonBasicProps;SkeletonAvatar 和 SkeletonParagraph 分别在此基础上增加自有 props。
  • loading 是单向 prop,不映射为 v-model;为 false 时只渲染默认插槽。
  • placeholder 同时支持 VNode prop 和同名插槽,插槽优先。

Vue 插槽 ​

Skeleton

插槽作用域参数说明
default{}加载完成后的内容
placeholder{}加载时的占位内容

Skeleton ​

属性说明类型默认值
active是否展示动画效果booleanfalse
classVue 原生类名HTMLAttributes['class']—
className样式类名HTMLAttributes['class']-
loading为 true 时,显示占位元素。反之则显示子组件booleantrue
placeholder加载等待时的占位元素VNodeChild-
style样式StyleValue-

Skeleton.Avatar ​

Skeleton.Image、Skeleton.Title、Skeleton.Button 使用公共 item props;size 和 shape 仅 Skeleton.Avatar 支持。

属性说明类型默认值
classVue 原生类名HTMLAttributes['class']—
className样式类名HTMLAttributes['class']-
prefixCls样式类名前缀stringsemi-skeleton
style样式StyleValue-
shape指定头像的形状,支持 circle、squareSkeletonAvatarShapecircle
size设置头像的大小,支持 extra-extra-small, extra-small、small、medium、large、extra-largeSkeletonAvatarSizemedium

Skeleton.Paragraph ​

属性说明类型默认值
classVue 原生类名HTMLAttributes['class']—
className样式类名HTMLAttributes['class']-
prefixCls样式类名前缀stringsemi-skeleton
style样式StyleValue-
rows设置段落占位图的行数number4

文案规范 ​

  • 不变的固定内容直接展示固定内容,可变的内容使用骨架屏展示