index.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <!-- components/Loading/index.vue-->
  3. <div v-show="isShow" class="loading">
  4. <div>
  5. <div class="loading-content">
  6. <img
  7. src="/logo.png"
  8. style="width: 400px; height: 400px"
  9. object-fit="cover"
  10. />
  11. </div>
  12. <div class="titleText">正在加载...</div>
  13. </div>
  14. </div>
  15. </template>
  16. <script setup lang="ts">
  17. import { ref } from "vue";
  18. const isShow = ref(true); //定位loading 的开关
  19. const show = () => {
  20. isShow.value = true;
  21. };
  22. const hide = () => {
  23. isShow.value = false;
  24. };
  25. //对外暴露 当前组件的属性和方法
  26. defineExpose({
  27. isShow,
  28. show,
  29. hide,
  30. });
  31. </script>
  32. <style scoped lang="scss">
  33. .loading {
  34. position: fixed;
  35. z-index: 999999;
  36. inset: 0;
  37. background: #f1f3f5;
  38. display: flex;
  39. justify-content: center;
  40. align-items: center;
  41. width: 100vw;
  42. height: 100vh;
  43. @include flex;
  44. .loading-content {
  45. animation: rotate 4s linear infinite;
  46. }
  47. .titleText {
  48. margin-top: 10px;
  49. text-align: center;
  50. }
  51. @keyframes rotate {
  52. from {
  53. transform: rotate(0deg);
  54. }
  55. to {
  56. transform: rotate(360deg);
  57. }
  58. }
  59. }
  60. </style>