our-loading.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <transition name="fade">
  3. <view
  4. class="mask"
  5. v-show="isActive"
  6. :class="{ 'full-screen': isFullScreen }"
  7. :style="{ backgroundColor }"
  8. >
  9. <view class="spinner" :style="{ transform:`translate(-50%, -${translateY}%)`}">
  10. <slot>
  11. <!-- ==========在这里改成选择的那一个========== -->
  12. <shrinkRect :color="color" :size="size"/>
  13. <!-- ==========在这里改成选择的那一个========== -->
  14. </slot>
  15. <view
  16. v-if="text.length"
  17. :style="{ color:textColor }">
  18. {{ text }}
  19. </view>
  20. </view>
  21. </view>
  22. </transition>
  23. </template>
  24. <script>
  25. // ==========在这里选一个你要的其他去掉也行==========
  26. // import loop from './loaders/loop.vue'
  27. // import bounce from './loaders/bounce.vue'
  28. // import doubleBounce from './loaders/double-bounce.vue'
  29. // import doubleCube from './loaders/double-cube.vue'
  30. // import doubleDot from './loaders/double-dot.vue'
  31. // import rotatePlane from './loaders/rotate-plane.vue'
  32. // import scaleOut from './loaders/scale-out.vue'
  33. import shrinkRect from './loaders/shrink-rect.vue'
  34. // ==========在这里选一个你要的其他去掉也行==========
  35. export default {
  36. name: 'ourLoading',
  37. components: {
  38. // ==========在这里选择一个==========
  39. // loop,
  40. // bounce,
  41. // doubleBounce,
  42. // doubleCube,
  43. // doubleDot,
  44. // rotatePlane,
  45. // scaleOut,
  46. shrinkRect
  47. // ==========在这里选择一个==========
  48. },
  49. props: {
  50. active: Boolean,
  51. translateY: {
  52. type: Number,
  53. default: 150
  54. },
  55. text: {
  56. type: String,
  57. default: ''
  58. },
  59. color: {
  60. type: String,
  61. default: '#333'
  62. },
  63. textColor: {
  64. type: String,
  65. default: '#333'
  66. },
  67. isFullScreen: {
  68. type: Boolean,
  69. default: false
  70. },
  71. backgroundColor: {
  72. type: String,
  73. default: 'rgba(255, 255, 255, .9)'
  74. },
  75. size: {
  76. type: Number,
  77. default: 40
  78. }
  79. },
  80. data () {
  81. return {
  82. isActive: this.active || false
  83. }
  84. },
  85. watch: {
  86. active (value) {
  87. this.isActive = value
  88. }
  89. }
  90. }
  91. </script>
  92. <style scoped>
  93. .mask {
  94. position: absolute;
  95. left: 0;
  96. right: 0;
  97. top: 0;
  98. bottom: 0;
  99. z-index: 3000;
  100. transition: opacity .3s linear;
  101. }
  102. .full-screen {
  103. position: fixed;
  104. top: 0;
  105. right: 0;
  106. bottom: 0;
  107. left: 0;
  108. }
  109. .spinner {
  110. position: absolute;
  111. top: 50%;
  112. left: 50%;
  113. text-align: center;
  114. }
  115. .fade-enter-active, .fade-leave-active {
  116. transition: opacity .3s;
  117. }
  118. .fade-enter, .fade-leave-to {
  119. opacity: 0;
  120. }
  121. </style>