customization.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <template>
  2. <el-button text @click="open">Click to open Message Box</el-button>
  3. </template>
  4. <script lang="ts" setup>
  5. import { h } from 'vue'
  6. import { ElMessage, ElMessageBox } from 'element-plus'
  7. const open = () => {
  8. ElMessageBox({
  9. title: 'Message',
  10. message: h('p', null, [h('span', null, 'Message can be '), h('i', { style: 'color: teal' }, 'VNode')]),
  11. showCancelButton: true,
  12. confirmButtonText: 'OK',
  13. cancelButtonText: 'Cancel',
  14. beforeClose: (action, instance, done) => {
  15. if (action === 'confirm') {
  16. instance.confirmButtonLoading = true
  17. instance.confirmButtonText = 'Loading...'
  18. setTimeout(() => {
  19. done()
  20. setTimeout(() => {
  21. instance.confirmButtonLoading = false
  22. }, 300)
  23. }, 3000)
  24. } else {
  25. done()
  26. }
  27. },
  28. }).then(action => {
  29. ElMessage({
  30. type: 'info',
  31. message: `action: ${action}`,
  32. })
  33. })
  34. }
  35. </script>