index.vue 913 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <script lang="ts" setup>
  2. import { alert, confirm, VbenButton } from '@vben/common-ui';
  3. function showConfirm() {
  4. confirm('This is an alert message')
  5. .then(() => {
  6. alert('Confirmed');
  7. })
  8. .catch(() => {
  9. alert('Canceled');
  10. });
  11. }
  12. function showIconConfirm() {
  13. confirm({
  14. content: 'This is an alert message with icon',
  15. icon: 'success',
  16. });
  17. }
  18. function showAsyncConfirm() {
  19. confirm({
  20. beforeClose() {
  21. return new Promise((resolve) => setTimeout(resolve, 2000));
  22. },
  23. content: 'This is an alert message with async confirm',
  24. icon: 'success',
  25. }).then(() => {
  26. alert('Confirmed');
  27. });
  28. }
  29. </script>
  30. <template>
  31. <div class="flex gap-4">
  32. <VbenButton @click="showConfirm">Confirm</VbenButton>
  33. <VbenButton @click="showIconConfirm">Confirm With Icon</VbenButton>
  34. <VbenButton @click="showAsyncConfirm">Async Confirm</VbenButton>
  35. </div>
  36. </template>