Empty Empty state
Display no-data, no-results, error or network states.
Import
Use <hui-empty> with uni-app easycom. Import public types from @nscode/handy-uni. For ordinary Vue 3, install the preview plugin from @nscode/handy-uni/web and register its components.
Examples
Interact with the controls to see values and event results on the page.
vue
<template>
<view>
<hui-empty description="暂无记录 / No records"
><hui-button @click="lastEvent = '重试 / Retry'">重试 / Retry</hui-button></hui-empty
>
<hui-empty type="search" /><hui-empty type="error" /><hui-empty type="network" />
<text>{{ lastEvent }}</text>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const lastEvent = ref('No event yet')
</script>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
type | EmptyType | 'empty' | Semantic type or input mode; see the type definition. |
image | string | — | Custom empty-state image. |
imageSize | EmptyImageSize | — | Image size in px; a number is square, or provide width and height. |
description | string | — | Description; an explicit empty string overrides fallback text. |
Root attributes: common props. A Boolean default of undefined supports inheritance; explicit false overrides it. Other Boolean props default to false unless listed otherwise.
Events
None.
Slots
| Slot | Parameters | Description |
|---|---|---|
image | — | Custom image region; replaces its fallback content. |
description | — | Custom description region; replaces its fallback content. |
default | — | Main content. |
Methods
None.
Types
EmptyProps、EmptyType、EmptyImageSize are available from @nscode/handy-uni.
ts
export type EmptyType = 'empty' | 'search' | 'error' | 'network'
export type EmptyImageSize = number | { width: number; height: number }
Platform notes
| Behavior | uni-app H5 | WeChat Mini Program | App-vue | Ordinary Vue 3 Web (preview) |
|---|---|---|---|---|
| Basic interaction | Supported; device checks pending | Supported; device checks pending | Supported; device checks pending | Supported by the web platform adapter |
Follow the smoke checklist. Device evidence is tracked separately; unit tests do not establish device acceptance.