alert.vue 541 B

12345678910111213141516171819202122
  1. <template>
  2. <el-button text @click="open">Click to open the Message Box</el-button>
  3. </template>
  4. <script lang="ts" setup>
  5. import { ElMessage, ElMessageBox } from 'element-plus'
  6. import type { Action } from 'element-plus'
  7. const open = () => {
  8. ElMessageBox.alert('This is a message', 'Title', {
  9. // if you want to disable its autofocus
  10. // autofocus: false,
  11. confirmButtonText: 'OK',
  12. callback: (action: Action) => {
  13. ElMessage({
  14. type: 'info',
  15. message: `action: ${action}`,
  16. })
  17. },
  18. })
  19. }
  20. </script>