test.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <div class="main_app">
  3. <el-button type="text" @click="dialogVisible = true"
  4. >click to open the Dialog</el-button
  5. >
  6. <el-dialog
  7. v-model="dialogVisible"
  8. title="Tips"
  9. width="30%"
  10. :before-close="handleClose"
  11. >
  12. <span>This is a message</span>
  13. <template #footer>
  14. <span class="dialog-footer">
  15. <el-button @click="dialogVisible = false">Cancel</el-button>
  16. <el-button type="primary" @click="dialogVisible = false"
  17. >Confirm</el-button
  18. >
  19. </span>
  20. </template>
  21. </el-dialog>
  22. </div>
  23. </template>
  24. <script setup>
  25. import { ref } from 'vue'
  26. import { ElMessageBox } from 'element-plus'
  27. const dialogVisible = ref(false)
  28. const handleClose = ( done => {
  29. ElMessageBox.confirm('Are you sure to close this dialog?')
  30. .then(() => {
  31. done()
  32. })
  33. .catch(() => {
  34. // catch error
  35. })
  36. });
  37. </script>
  38. <style>
  39. .main_app {
  40. font-family: 'Avenir', Helvetica, Arial, sans-serif;
  41. -webkit-font-smoothing: antialiased;
  42. -moz-osx-font-smoothing: grayscale;
  43. text-align: center;
  44. color: #2c3e50;
  45. margin-top: 60px;
  46. }
  47. </style>