fullscreen.vue 750 B

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