Skeleton 骨架屏

骨架屏组件,用于数据加载时的占位展示

是否显示骨架屏

演示

9:41

代码示例

<!-- 基础用法 -->
  <re-skeleton class="demo-skeleton-loading" :loading="true" />

<!-- 不同类型 -->
  <re-skeleton class="demo-skeleton-avatar" :loading="true" theme="avatar" />
  <re-skeleton class="demo-skeleton-image" :loading="true" theme="image" />
  <re-skeleton class="demo-skeleton-text" :loading="true" theme="text" />
  <re-skeleton class="demo-skeleton-paragraph" :loading="true" theme="paragraph" />

<!-- 动画效果 -->
  <re-skeleton class="demo-skeleton-gradient" :loading="true" animation="gradient" theme="paragraph" />
  <re-skeleton class="demo-skeleton-flashed" :loading="true" animation="flashed" theme="paragraph" />
  <re-skeleton class="demo-skeleton-none" :loading="true" animation="none" theme="paragraph" />

<!-- 段落行数 -->
  <re-skeleton class="demo-skeleton-rows-1" :loading="true" theme="paragraph" :rows="1" />
  <re-skeleton class="demo-skeleton-rows-3" :loading="true" theme="paragraph" :rows="3" />
  <re-skeleton class="demo-skeleton-rows-5" :loading="true" theme="paragraph" :rows="5" />

<!-- 非加载状态 -->
  <re-skeleton class="demo-skeleton-not-loading" :loading="false"> <text>加载完成的内容</text> </re-skeleton>

<!-- 自定义样式 -->
  <re-skeleton class="demo-skeleton-custom-style" :loading="true" theme="text" customStyle="margin-top: 10px;" />

<!-- 头像骨架 -->
  <re-skeleton class="demo-skeleton-avatar-gradient" :loading="true" theme="avatar" animation="gradient" />
  <re-skeleton class="demo-skeleton-avatar-flashed" :loading="true" theme="avatar" animation="flashed" />

<!-- 图片骨架 -->
  <re-skeleton class="demo-skeleton-image-gradient" :loading="true" theme="image" animation="gradient" />
  <re-skeleton class="demo-skeleton-image-none" :loading="true" theme="image" animation="none" />

引入

推荐使用 easycom 模式,配置后无需手动 import 即可直接使用 <re-skeleton />。

API

Skeleton Props

名称类型默认值描述必传
loadingbooleantrue是否显示骨架屏Y
animationstringgradient动画效果,可选值:none/gradient/flashedY
themestringtext骨架屏类型,可选值:avatar/image/text/paragraphY
rowsnumber4段落行数Y
customStylestring''自定义样式Y

Skeleton Events

名称参数描述
click-点击时触发

Skeleton Slots

名称描述
default默认插槽