Skip to content

Skeleton 骨架屏

用于内容加载时的占位,提升页面加载体验。

基本用法

最简单的骨架屏用法:

vue
<template>
  <up-skeleton />
</template>

动画效果

通过 animate 属性控制骨架屏是否显示动画效果,通常与加载状态联动。

vue
<template>
  <up-skeleton :animate="isShowLoading" />
</template>

<script setup>
import { ref } from 'vue'
const isShowLoading = ref(false)
</script>

头像骨架

通过 type="avatar" 显示头像骨架,可设置 avatarSizeavatarShape

vue
<template>
  <up-skeleton type="avatar" :avatarSize="80" avatarShape="circle" />
</template>

标题行数

通过 rows 属性设置骨架屏的行数。

vue
<template>
  <up-skeleton :rows="1" />
</template>

标题宽度

通过 titleWidth 属性设置标题宽度。

vue
<template>
  <up-skeleton titleWidth="50%" />
</template>

Props

参数说明类型默认值
type骨架屏类型string'title'
loading是否显示骨架booleantrue
animate是否显示动画booleantrue
avatarShape头像形状string'circle'
avatarSize头像大小number/string60
titleHeight段落高度number/string36
titleWidth段落宽度number/string'100%'
rows行数number3

源代码

文档
组件

Released under the MIT License.

Released under the MIT License.