Skip to content

t-empty

Empty 空状态

组件介绍

空白页占位组件,用于在应用中显示一个空状态页面,通常在没有数据或内容可显示时使用。它提供默认或自定义的占位图像,支持自定义标题和描述文本,以及可固定在页面中心的位置。

平台兼容

HarmonyH5AndroidiOS小程序UTS

基础用法

vue
<template>
  <view class="container">
    <!-- 默认空状态 -->
    <t-empty class="mb-40"></t-empty>
    
    <!-- 搜索无结果 -->
    <t-empty mode="search" title="搜索无结果" descr="没有找到相关内容" class="mb-40"></t-empty>
    
    <!-- 网络错误 -->
    <t-empty mode="network" title="网络错误" descr="请检查网络连接后重试" class="mb-40"></t-empty>
    
    <!-- 自定义图片 -->
    <t-empty src="https://example.com/empty.png" title="自定义空状态" descr="这是一个自定义的空状态页面" class="mb-40"></t-empty>
    
    <!-- 固定在页面中心 -->
    <t-empty mode="address" title="暂无地址" descr="请添加收货地址" isFixed></t-empty>
  </view>
</template>

<style scoped>
.container {
  padding: 40rpx;
  min-height: 800rpx;
}

.mb-40 {
  margin-bottom: 40rpx;
}
</style>

Props

属性名类型默认值说明可选值
sizeString"medium"组件尺寸large, medium, small, mini
typeString""组件类型info, primary, error, warning, success
disabledBooleanfalse组件是否禁用true, false
hoverBooleanfalse是否有点击效果true, false
pathString""点击组件后跳转的页面路径-
effectString""组件显示主题normal, dark, light, plain
modeString"order"显示模式order, news, address, network, search
srcString""替换默认图的图片地址-
imageClassString""图片样式-
titleString""标题-
titleClassString""标题的样式-
descrString""描述文本-
descrClassString""描述的文本的样式-
isFixedBooleanfalse是否固定true, false

Events

事件名说明回调参数
click点击时触发-
transitionend动画结束时触发-
initFinished组件初始化完成触发组件的节点信息
touchstart触摸开始时触发触摸事件对象
touchend触摸结束时触发触摸事件对象
touchmove触摸移动时触发触摸事件对象
touchcancel触摸取消时触发触摸事件对象

Slots

插槽名说明
default自定义内容插槽,用于替换默认的空状态内容