fullscreen.vue 733 B

12345678910111213141516171819202122232425262728293031323334
  1. <template>
  2. <el-button
  3. v-loading.fullscreen.lock="fullscreenLoading"
  4. type="primary"
  5. @click="openFullScreen1"
  6. >
  7. As a directive
  8. </el-button>
  9. <el-button type="primary" @click="openFullScreen2"> As a service </el-button>
  10. </template>
  11. <script lang="ts" setup>
  12. import { ref } from 'vue'
  13. import { ElLoading } from 'element-plus'
  14. const fullscreenLoading = ref(false)
  15. const openFullScreen1 = () => {
  16. fullscreenLoading.value = true
  17. setTimeout(() => {
  18. fullscreenLoading.value = false
  19. }, 2000)
  20. }
  21. const openFullScreen2 = () => {
  22. const loading = ElLoading.service({
  23. lock: true,
  24. text: 'Loading',
  25. background: 'rgba(0, 0, 0, 0.7)',
  26. })
  27. setTimeout(() => {
  28. loading.close()
  29. }, 2000)
  30. }
  31. </script>