customization.vue 973 B

123456789101112131415161718192021222324252627282930313233343536373839
  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, [
  11. h('span', null, 'Message can be '),
  12. h('i', { style: 'color: teal' }, 'VNode'),
  13. ]),
  14. showCancelButton: true,
  15. confirmButtonText: 'OK',
  16. cancelButtonText: 'Cancel',
  17. beforeClose: (action, instance, done) => {
  18. if (action === 'confirm') {
  19. instance.confirmButtonLoading = true
  20. instance.confirmButtonText = 'Loading...'
  21. setTimeout(() => {
  22. done()
  23. setTimeout(() => {
  24. instance.confirmButtonLoading = false
  25. }, 300)
  26. }, 3000)
  27. } else {
  28. done()
  29. }
  30. },
  31. }).then((action) => {
  32. ElMessage({
  33. type: 'info',
  34. message: `action: ${action}`,
  35. })
  36. })
  37. }
  38. </script>