Loading.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <view v-if="visible" class="loading-wrap">
  3. <view class="loading-content">
  4. <view class="loading-spinner"></view>
  5. <text v-if="title" class="loading-text">{{ title }}</text>
  6. </view>
  7. </view>
  8. </template>
  9. <script setup lang="ts">withDefaults(
  10. defineProps<{
  11. visible: boolean
  12. title?: string
  13. }>(),
  14. {
  15. title: '加载中...'
  16. }
  17. )
  18. </script>
  19. <style scoped>
  20. .loading-wrap {
  21. position: fixed;
  22. top: 0;
  23. left: 0;
  24. right: 0;
  25. bottom: 0;
  26. display: flex;
  27. align-items: center;
  28. justify-content: center;
  29. z-index: 9999;
  30. background: rgba(255, 255, 255, 0.6);
  31. }
  32. .loading-content {
  33. padding: 20px 24px;
  34. background: rgba(0, 0, 0, 0.7);
  35. border-radius: 8px;
  36. display: flex;
  37. flex-direction: column;
  38. align-items: center;
  39. justify-content: center;
  40. }
  41. .loading-spinner {
  42. width: 28px;
  43. height: 28px;
  44. border: 3px solid rgba(255, 255, 255, 0.3);
  45. border-top-color: #fff;
  46. border-radius: 50%;
  47. animation: spin 0.8s linear infinite;
  48. }
  49. .loading-text {
  50. margin-top: 10px;
  51. font-size: 14px;
  52. color: #fff;
  53. }
  54. @keyframes spin {
  55. to {
  56. transform: rotate(360deg);
  57. }
  58. }
  59. </style>