loading.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. export default {
  9. data() {
  10. return {}
  11. },
  12. props: {
  13. size: {
  14. type: Number,
  15. default: 100
  16. },
  17. iconColor: {
  18. type: String,
  19. default: ''
  20. },
  21. mask: {
  22. type: Boolean,
  23. default: true
  24. }
  25. },
  26. computed: {
  27. icontStyle() {
  28. let style = `font-size:${this.size}rpx;`;
  29. if(this.iconColor){
  30. style += `color: ${this.iconColor};`
  31. }else if(this.mask){
  32. style += 'color: #eee;'
  33. }
  34. return style;
  35. },
  36. loadingStyle() {
  37. return this.mask ? "background: rgba(0, 0, 0, 0.3);" : "";
  38. }
  39. }
  40. }
  41. </script>
  42. <style lang="scss" scoped>
  43. .loading-box {
  44. width: 100%;
  45. height: 100%;
  46. position: absolute;
  47. left: 0;
  48. top: 0;
  49. z-index: 10000;
  50. display: flex;
  51. justify-content: center;
  52. align-items: center;
  53. }
  54. .rotate {
  55. animation: rotate 2s ease-in-out infinite;
  56. }
  57. @keyframes rotate {
  58. from {
  59. transform: rotate(0deg)
  60. }
  61. to {
  62. transform: rotate(360deg)
  63. }
  64. }
  65. </style>