更新记录
1.0.1(2025-11-15)
下载此版本
修复已知问题
1.0.0(2025-10-29)
下载此版本
初始功能
平台兼容性
uni-app(4.66)
| Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
| √ |
√ |
√ |
√ |
√ |
√ |
√ |
√ |
√ |
| 微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
快应用-华为 |
快应用-联盟 |
| √ |
√ |
√ |
√ |
√ |
√ |
√ |
√ |
√ |
√ |
√ |
liaction-status
一个功能丰富的状态展示组件,支持加载中、错误、空数据等多种状态的灵活配置和自定义。
特性
- 支持多种预设状态:loading(加载中)、error(错误)、empty(无数据)
- 支持自定义状态和样式
- 灵活的配置选项,可自定义文本、图标、颜色等
- 支持自动高度或固定高度显示
- 提供按钮交互功能
- 完全支持插槽自定义内容
安装
通过 uni_modules 直接导入组件。
使用示例
基础使用
<template>
<view>
<!-- 加载中状态 -->
<liaction-status status="loading" />
<!-- 错误状态,带按钮 -->
<liaction-status
status="error"
showButton
@button-click="handleErrorReload"
/>
<!-- 空数据状态,自定义文本和图标 -->
<liaction-status
status="empty"
text="暂无记录"
iconType="document"
/>
<!-- 自定义错误状态图标 -->
<liaction-status status="error">
<template #error-icon>
<view class="custom-error-icon" style="width: 48px; height: 48px; background-color: #FF6B3B; border-radius: 8px;">
<text style="color: white; font-size: 28px;">!</text>
</view>
</template>
</liaction-status>
<!-- 自定义空状态图标 -->
<liaction-status status="empty">
<template #empty-icon>
<view class="custom-empty-icon" style="width: 48px; height: 48px; background-color: #C9CDD4; border-radius: 8px;">
<text style="color: white; font-size: 28px;">📄</text>
</view>
</template>
</liaction-status>
</view>
</template>
<script>
export default {
methods: {
handleErrorReload() {
console.log('重新加载数据');
// 执行重新加载操作
}
}
}
</script>
自定义状态
<template>
<view>
<!-- 自定义状态 -->
<liaction-status
status="success"
:customSlots="customSlots"
>
<!-- 自定义成功状态内容 -->
<template #success>
<uni-icons type="success-circle" size="48" color="#4CD964" />
<text class="success-text">操作成功</text>
<button type="primary" size="mini" @click="handleSuccess">确定</button>
</template>
</liaction-status>
</view>
</template>
<script>
export default {
data() {
return {
customSlots: [
{
name: 'success'
}
]
}
},
methods: {
handleSuccess() {
console.log('操作成功确认');
}
}
}
</script>
属性说明
| 属性名 |
类型 |
默认值 |
说明 |
| status |
String |
必填 |
状态类型:loading、error、empty 或自定义状态名 |
| customSlots |
Array |
[] |
自定义状态插槽配置数组 |
| text |
String |
'' |
显示文本,优先级高于各状态默认文本 |
| loadingIconSize |
Number |
30 |
加载中状态图标大小 |
| loadingIconColor |
String |
'' |
加载中状态图标颜色 |
| loadingText |
String |
'加载数据中' |
加载中状态默认文本 |
| errorText |
String |
'获取数据失败' |
错误状态默认文本 |
| emptyText |
String |
'暂无相关数据' |
空状态默认文本 |
| errorButtonText |
String |
'重新加载' |
错误状态按钮文本 |
| emptyButtonText |
String |
'刷新' |
空状态按钮文本 |
| showButton |
Boolean |
false |
是否显示按钮 |
| buttonText |
String |
'' |
按钮文本(兼容旧版,优先级低于具体状态的按钮文本) |
| customClass |
String |
'' |
自定义类名 |
| autoHeight |
Boolean |
false |
是否自动高度(false:高度100%, true:自适应高度) |
事件说明
| 事件名 |
说明 |
回调参数 |
| button-click |
按钮点击时触发 |
无 |
插槽说明
| 插槽名 |
说明 |
| loading |
加载中状态自定义内容 |
| error |
错误状态的完整内容 |
| error-icon |
自定义错误状态的图标(仅当使用默认error插槽时生效) |
| empty |
空数据状态的完整内容 |
| empty-icon |
自定义空数据状态的图标(仅当使用默认empty插槽时生效) |
| [自定义状态名] |
自定义状态的内容插槽 |
| default |
默认插槽,当未匹配到任何状态时使用 |