loading.vue 948 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <view class="loading-box" :style="loadingStyle">
  3. <view class="rotate iconfont icon-loading" :style="icontStyle"></view>
  4. <slot></slot>
  5. </view>
  6. </template>
  7. <script>
  8. import {
  9. computed
  10. } from "vue"
  11. export default {
  12. data() {
  13. return {}
  14. },
  15. props: {
  16. size: {
  17. type: Number,
  18. default: 100
  19. },
  20. mask: {
  21. type: Boolean,
  22. default: true
  23. }
  24. },
  25. computed: {
  26. icontStyle() {
  27. return `font-size:${this.size}rpx`;
  28. },
  29. loadingStyle() {
  30. return this.mask ? "background: rgba(0, 0, 0, 0.3);" : "";
  31. }
  32. }
  33. }
  34. </script>
  35. <style lang="scss" scoped>
  36. .loading-box {
  37. width: 100%;
  38. height: 100%;
  39. position: absolute;
  40. left: 0;
  41. top: 0;
  42. z-index: 10000;
  43. display: flex;
  44. justify-content: center;
  45. align-items: center;
  46. }
  47. .rotate {
  48. animation: rotate 2s ease-in-out infinite;
  49. }
  50. @keyframes rotate {
  51. from {
  52. transform: rotate(0deg)
  53. }
  54. to {
  55. transform: rotate(360deg)
  56. }
  57. }
  58. </style>