You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
913 B

  1. <!-- @format -->
  2. <template>
  3. <view v-if="loading" class="loading">
  4. <image class="loadingGif" src="/static/loading-gif.gif" mode=""></image>
  5. </view>
  6. </template>
  7. <script setup>
  8. import { ref, computed, onMounted,watch } from "vue";
  9. // 定义 props
  10. const props = defineProps({
  11. loading: {
  12. type: Boolean,
  13. default: false,
  14. },
  15. });
  16. const loading = ref(false);
  17. // 监听 props.loading 变化
  18. watch(() => props.loading, (newVal) => {
  19. loading.value = newVal;
  20. });
  21. // 生命周期
  22. onMounted(() => {
  23. loading.value = props.loading;
  24. });
  25. </script>
  26. <style scoped>
  27. .loading {
  28. position: absolute;
  29. top: 0;
  30. left: 0;
  31. width: 100%;
  32. height: 100%;
  33. background-color: rgba(0, 0, 0, 0.5);
  34. display: flex;
  35. justify-content: center;
  36. align-items: center;
  37. z-index: 9999;
  38. display: flex;
  39. justify-content: center;
  40. align-items: center;
  41. }
  42. .loadingGif {
  43. width: 100rpx;
  44. height: 100rpx;
  45. }
  46. </style>