index.vue 1.0 KB

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