Empty 空状态
展示无数据、无结果、错误或网络异常。
引入
uni-app 配置 easycom 后使用 <hui-empty>;公开类型从 @nscode/handy-uni 导入。普通 Vue 3 项目安装 @nscode/handy-uni/web 预览版插件后使用同名组件。
示例
操作控件后,页面直接显示当前值和事件结果。
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('尚无事件')
</script>
Props
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
type | EmptyType | 'empty' | 决定默认图和默认文字;错误和空数据分开(清单 M24) |
image | string | — | 图片地址,替换默认图 |
imageSize | EmptyImageSize | — | 和 PC 同义 |
description | string | — | 不传时按 type 取默认文字;传 '' 不显示 |
根节点属性见通用属性。布尔默认值为 undefined 时支持继承;显式 false 会覆盖继承值。其他布尔值按表中默认值处理。
Events
无。
Slots
| 插槽 | 参数 | 说明 |
|---|---|---|
image | — | 自定义 image 区域,覆盖默认内容。 |
description | — | 自定义 description 区域,覆盖默认内容。 |
default | — | 主体内容。 |
方法
无。
类型
EmptyProps、EmptyType、EmptyImageSize 可从 @nscode/handy-uni 导入。
ts
export type EmptyType = 'empty' | 'search' | 'error' | 'network'
export type EmptyImageSize = number | { width: number; height: number }
平台说明
| 行为 | uni-app H5 | 微信小程序 | App-vue | 普通 Vue 3 Web(预览) |
|---|---|---|---|---|
| 基本交互 | 已实现,待设备复核 | 已实现,待设备复核 | 已实现,待设备复核 | 由 Web 平台适配层实现 |
设备操作见冒烟清单。真实设备读数单独记录,单元测试通过不代表真机验收。