empty-state.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <view class="empty-box">
  3. <text v-if="icon" class="empty-icon">{{ icon }}</text>
  4. <text class="empty-title">{{ title }}</text>
  5. <text v-if="desc" class="empty-desc">{{ desc }}</text>
  6. <button v-if="actionText" class="empty-btn" @click="handleAction">{{ actionText }}</button>
  7. </view>
  8. </template>
  9. <script>
  10. /**
  11. * 空态占位(分子组件):统一文案/图标/CTA
  12. */
  13. export default {
  14. name: 'EmptyState',
  15. props: {
  16. icon: { type: String, default: '📭' },
  17. title: { type: String, default: '暂无数据' },
  18. desc: { type: String, default: '' },
  19. actionText: { type: String, default: '' }
  20. },
  21. methods: {
  22. handleAction() {
  23. this.$emit('action')
  24. }
  25. }
  26. }
  27. </script>
  28. <style scoped>
  29. .empty-box {
  30. background: #FFFFFF;
  31. border: 1px solid #E3ECF4;
  32. border-radius: 20rpx;
  33. padding: 56rpx 36rpx;
  34. display: flex;
  35. flex-direction: column;
  36. align-items: center;
  37. }
  38. .empty-icon { font-size: 72rpx; margin-bottom: 20rpx; }
  39. .empty-title { font-size: 30rpx; font-weight: 600; color: #1F4E79; margin-bottom: 12rpx; }
  40. .empty-desc { font-size: 24rpx; color: #3B5A78; text-align: center; line-height: 1.7; margin-bottom: 28rpx; }
  41. .empty-btn {
  42. width: 60%;
  43. height: 80rpx;
  44. line-height: 80rpx;
  45. background: #2E6FA8;
  46. color: #FFFFFF;
  47. font-size: 28rpx;
  48. font-weight: 600;
  49. border-radius: 40rpx;
  50. border: none;
  51. padding: 0;
  52. }
  53. .empty-btn:active { opacity: 0.9; }
  54. </style>