Empty空状态
Empty 空状态
空状态时的展示占位图。
何时使用
-
当目前没有数据时,用于显式的用户提示。
-
初始化场景时的引导创建流程。
代码演示
基本用法
简单的展示。
<template> <a-empty /></template>
选择图片
可以通过设置 image 为 Empty.PRESENTED_IMAGE_SIMPLE 选择另一种风格的图片。
<template> <a-empty :image="simpleImage" /></template><script lang="ts">import { defineComponent } from 'vue';import { Empty } from 'ant-design-vue';export default defineComponent({ setup() { return { simpleImage: Empty.PRESENTED_IMAGE_SIMPLE, }; },});</script>
自定义
自定义图片、描述、附属内容。
<template> <a-empty image="https://gw.alipayobjects.com/mdn/miniapp_social/afts/img/A*pevERLJC9v0AAAAAAAAAAABjAQAAAQ/original" :image-style="{ height: '60px', }" > <template #description> <span> Customize <a href="#API">Description</a> </span> </template> <a-button type="primary">Create Now</a-button> </a-empty></template>
default
全局化配置
自定义全局组件的 Empty 样式。
<template> <a-switch un-checked-children="default" checked-children="customize" v-model:checked="customize" /> <a-divider /> <a-config-provider> <template v-if="customize" #renderEmpty> <div style="text-align: center"> <smile-outlined style="font-size: 20px" /> <p>Data Not Found</p> </div> </template> <div class="config-provider"> <h3>Select</h3> <a-select :style="style" :options="[]" /> <h3>TreeSelect</h3> <a-tree-select :style="style" :tree-data="[]" /> <h3>Cascader</h3> <a-cascader :style="style" :options="[]" :show-search="true" /> <h3>Transfer</h3> <a-transfer :data-source="[]" /> <h3>Table</h3> <a-table style="margin-top: 8px" :columns="columns" :data-source="[]" /> <h3>List</h3> <a-list :data-source="[]" /> </div> </a-config-provider></template><script lang="ts">import { SmileOutlined } from '@ant-design/icons-vue';import { defineComponent, ref } from 'vue';export default defineComponent({ components: { SmileOutlined, }, setup() { const customize = ref<boolean>(false); return { customize, style: { width: '200px' }, columns: [{ title: 'Name' }, { title: 'Age' }], }; },});</script><style scoped>.code-box-demo .config-provider h3 { font-size: inherit; margin: 16px 0 8px 0;}</style>
无描述
无描述展示。
<template> <a-empty :description="false" /></template>
API
<Empty> <Button>创建</Button></Empty>
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|---|---|---|---|---|
| description | 自定义描述内容 | string | v-slot | - | | |---|---|---|---|---|
| imageStyle | 图片样式 | CSSProperties | - | |
|---|---|---|---|---|
| image | 设置显示图片,为 string 时表示自定义图片地址 | string | v-slot | false | | |---|---|---|---|---|
内置图片
- Empty.PRESENTED_IMAGE_SIMPLE
- Empty.PRESENTED_IMAGE_DEFAULT
