buddhism/components/status-display/status-display.vue
2025-07-31 16:36:14 +08:00

71 lines
1.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="status-display">
<!-- 加载状态 -->
<view v-if="type === 'loading'" class="loading">
<text>{{ loadingText }}</text>
</view>
<!-- 空数据提示 -->
<view v-else-if="type === 'empty'" class="empty">
<text>{{ emptyText }}</text>
</view>
<!-- 错误状态 -->
<view v-else-if="type === 'error'" class="error">
<text>{{ errorText }}</text>
</view>
</view>
</template>
<script>
export default {
name: 'StatusDisplay',
props: {
// 状态类型loading, empty, error
type: {
type: String,
required: true,
validator: value => ['loading', 'empty', 'error'].includes(value),
default: 'loading'
},
// 加载文本
loadingText: {
type: String,
default: '加载中...'
},
// 空数据文本
emptyText: {
type: String,
default: '暂无数据'
},
// 错误文本
errorText: {
type: String,
default: '加载失败'
}
}
}
</script>
<style lang="scss" scoped>
.status-display {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
min-height: 200rpx;
}
.loading, .empty, .error {
display: flex;
justify-content: center;
align-items: center;
color: #999;
font-size: 28rpx;
background-color: #FFFBF5;
padding: 40rpx 0;
border-radius: 8rpx;
}
.error {
color: #ff6b6b;
}
</style>