Skip to content

Empty 空状态

空状态时的占位提示。

基础用法

暂无数据

vue
<template>
  <x-empty />
</template>

自定义描述

设置 description 属性自定义描述文字。

没有找到相关数据

vue
<template>
  <x-empty description="没有找到相关数据" />
</template>

自定义图片

通过 image 属性设置图片地址,通过 image-size 属性设置图片大小。

自定义图片

vue
<template>
  <x-empty
    image="https://empty-demo.png"
    :image-size="100"
    description="自定义图片"
  />
</template>

自定义底部内容

使用默认插槽在底部插入内容。

暂无数据

vue
<template>
  <x-empty description="暂无数据">
    <x-button type="primary" size="small">添加数据</x-button>
  </x-empty>
</template>

自定义图片插槽

使用 image 插槽自定义图片内容。

📭
没有消息通知
vue
<template>
  <x-empty>
    <template #image>
      <div style="font-size: 60px; color: #c0c4cc;">📭</div>
    </template>
    <template #description>
      <span style="color: #909399;">没有消息通知</span>
    </template>
  </x-empty>
</template>

不同尺寸

通过 size 属性设置组件尺寸。

small

小尺寸

default

默认尺寸

large

大尺寸

vue
<template>
  <x-empty size="small" description="小尺寸" />
  <x-empty description="默认尺寸" />
  <x-empty size="large" description="大尺寸" />
</template>

API

Props

属性说明类型默认值
image图片地址string默认空状态图片
image-size图片尺寸number
description描述文字string'暂无数据'
size尺寸'large' | 'default' | 'small''default'

Slots

插槽名说明参数
default自定义底部内容
image自定义图片
description自定义描述

基于 MIT 许可发布