Skip to content

Skeleton 骨架屏

介绍

在页面上待加载区域填充灰色的占位图,本质上是界面加载过程中的过渡效果。

基础用法

html
<template>
  <nut-skeleton width="250px" height="15px" animated></nut-skeleton>
</template>

传入多行

html
<template>
  <nut-skeleton
    width="250px"
    height="15px"
    title
    animated
    row="3"
  ></nut-skeleton>
</template>

显示头像

html
<template>
  <nut-skeleton
    width="250px"
    height="15px"
    title
    animated
    avatar
    avatar-size="60px"
    row="3"
  ></nut-skeleton>
</template>

标题段落圆角风格

html
<template>
  <nut-skeleton
    width="250px"
    height="15px"
    animated
    round
  ></nut-skeleton>
</template>

组合

html
<template>
  <view>
    <nut-skeleton
      width="250px"
      height="15px"
      title
      animated
      row="3"
    ></nut-skeleton>

    <nut-skeleton
      width="250px"
      height="15px"
      title
      animated
      row="3"
    ></nut-skeleton>
  </view>
</template>

显示子组件

html
<template>
  <nut-switch v-model="loading"></nut-switch>

  <nut-skeleton
    width="250px"
    height="15px"
    title
    animated
    avatar
    row="3"
    :loading="loading"
  >
    <view class="flex flex-col">
      <nut-avatar size="50">
        <image src="https://xxx.xx"></image>
      </nut-avatar>
      <text>NutUI</text>
      <text>一套京东风格的轻量级移动端Vue组库,提供丰富的基础组件和业务组件,帮助开发者快速搭建移动应用。</text>
    </view>
  </nut-skeleton>
</template>

API

Props

参数说明类型可选值默认值
loading是否显示骨架屏boolean-true
width每行宽度string-100px
height每行高度string-15px
animated是否开启骨架屏动画boolean-false
avatar是否显示头像boolean-false
avatar-shape头像形状stringround / squareround
avatar-size头像大小string-50px
round标题 / 段落是否采用圆角风格boolean-false
row设置段落行数string-1
title是否显示段落标题boolean-true

Slots

名称说明
default骨架屏显示内容

主题定制

样式变量

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 组件

名称默认值
--nut-skeleton-content-avatar-background-color#efefef
--nut-skeleton-content-line-background-color#efefef
--nut-skeleton-animation-background-colorlinear-gradient(90deg,hsla(0, 0%, 100%, 0),hsla(0, 0%, 100%, 0.5) 50%, hsla(0, 0%, 100%, 0) 80%)

MIT Licensed