NoData.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <view class="no-data-container" :style="{ padding: padding }">
  3. <!-- 暂无数据图标 -->
  4. <uni-icons
  5. type="empty"
  6. size="60"
  7. color="#ccc"
  8. class="no-data-icon"
  9. ></uni-icons>
  10. <!-- 暂无数据文本 -->
  11. <text class="no-data-text" :style="{ color: textColor, fontSize: fontSize + 'px' }">
  12. {{ text || '暂无数据' }}
  13. </text>
  14. </view>
  15. </template>
  16. <script setup lang="ts">
  17. import { defineProps } from 'vue';
  18. // 定义组件属性,支持自定义样式和文本
  19. const props = defineProps({
  20. // 自定义暂无数据文本,默认“暂无数据”
  21. text: {
  22. type: String,
  23. default: '暂无数据'
  24. },
  25. // 文本颜色,默认浅灰色
  26. textColor: {
  27. type: String,
  28. default: '#999'
  29. },
  30. // 文本字号,默认14px
  31. fontSize: {
  32. type: Number,
  33. default: 14
  34. },
  35. // 容器内边距,默认上下30px,左右0
  36. padding: {
  37. type: String,
  38. default: '30px 0'
  39. }
  40. });
  41. </script>
  42. <style scoped>
  43. .no-data-container {
  44. display: flex;
  45. flex-direction: column;
  46. align-items: center;
  47. justify-content: center;
  48. width: 100%;
  49. }
  50. .no-data-icon {
  51. margin-bottom: 12px;
  52. }
  53. .no-data-text {
  54. line-height: 1.5;
  55. }
  56. </style>