loading.vue 905 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <a-spin
  3. :class="{
  4. 'my-loading-default':true,
  5. 'my-loading-css':(loadingState===0)}"
  6. :spinning="loadingState===0"
  7. :tip="tip">
  8. <!-- 加载中-->
  9. <slot v-if="loadingState===1" ></slot>
  10. <!-- 加载成功插槽-->
  11. <slot v-else-if="loadingState===2" name="loadFail"></slot>
  12. <!-- 加载失败插槽 -->
  13. </a-spin>
  14. </template>
  15. <script>
  16. export default {
  17. name: "loading",
  18. props: {
  19. tip: {
  20. default: 'Loading...'
  21. },
  22. size: {
  23. default: 'default',
  24. },
  25. // 加载状态 0加载中 1加载失败 2加载成功
  26. loadingState: {
  27. default: 0
  28. }
  29. },
  30. }
  31. </script>
  32. <style >
  33. .my-loading-default{
  34. width: 100%;
  35. height: 100%;
  36. }
  37. .my-loading-css{
  38. display: flex;
  39. justify-content: center;
  40. align-items: center;
  41. flex-direction: column;
  42. }
  43. .ant-spin-container{
  44. width: 100%;
  45. height: 100%;
  46. }
  47. </style>