74 lines
1.5 KiB
Vue
74 lines
1.5 KiB
Vue
<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>
|