index.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <div class="_loading" v-if="visible">
  3. <div class="wind-loading">
  4. <div class="wind-loading-bg"></div>
  5. <div class="wind-loading-dialog">
  6. <div class="wind-loading-content">
  7. <slot name="content">
  8. <i class="el-icon-loading"></i>
  9. <div class="content-text" v-html="message"></div>
  10. </slot>
  11. </div>
  12. <div class="wind-loading-btn" @click="close">{{btnName}}</div>
  13. </div>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. import { defineComponent, ref } from 'vue'
  19. // 组件介绍:本组件是可关闭的loading加载组件,一般适用于耗时比较长接口连接调用
  20. export default defineComponent({
  21. name: 'CipCancelLoading',
  22. props: {
  23. message: { type: String, default: 'loading' },
  24. btnName: { type: String, default: '退出' },
  25. onCancel: { type: Function, default: () => {} }
  26. },
  27. emits: ['vanish'],
  28. setup (props, { emit }) {
  29. const visible = ref(false)
  30. const close = () => {
  31. visible.value = false
  32. emit('vanish')
  33. }
  34. return {
  35. visible,
  36. close
  37. }
  38. }
  39. })
  40. </script>
  41. <style scoped>
  42. .wind-loading-dialog {
  43. top: 50%;
  44. left: 50%;
  45. opacity: 1;
  46. position: fixed;
  47. transform: translate(-50%, -50%);
  48. color: #000;
  49. z-index: 99999;
  50. }
  51. .wind-loading-bg {
  52. top: 0;
  53. left: 0;
  54. width: 100%;
  55. height: 100%;
  56. opacity: 0.3;
  57. display: block;
  58. position: fixed;
  59. z-index: 9999;
  60. background-color: #000;
  61. }
  62. .wind-loading-content {
  63. text-align: center;
  64. }
  65. .el-icon-loading {
  66. font-size: 100px;
  67. margin-right: 40px;
  68. }
  69. .content-text {
  70. font-size: 16px;
  71. text-align: left;
  72. }
  73. .wind-loading-btn {
  74. color: #000;
  75. border-radius: 4px;
  76. border: 1px solid #000;
  77. padding: 10px 30px;
  78. font-size: 15px;
  79. text-align: center;
  80. margin-top: 10px;
  81. cursor: pointer;
  82. width: 140px;
  83. }
  84. </style>