index.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <script lang="ts" setup>
  2. import { Button, Card, message, notification, Space } from 'ant-design-vue';
  3. type NotificationType = 'error' | 'info' | 'success' | 'warning';
  4. function info() {
  5. message.info('How many roads must a man walk down');
  6. }
  7. function error() {
  8. message.error({
  9. content: 'Once upon a time you dressed so fine',
  10. duration: 2500,
  11. });
  12. }
  13. function warning() {
  14. message.warning('How many roads must a man walk down');
  15. }
  16. function success() {
  17. message.success('Cause you walked hand in hand With another man in my place');
  18. }
  19. function notify(type: NotificationType) {
  20. notification[type]({
  21. duration: 2500,
  22. message: '说点啥呢',
  23. type,
  24. });
  25. }
  26. </script>
  27. <template>
  28. <div class="p-5">
  29. <div class="card-box p-5">
  30. <h1 class="text-xl font-semibold">Ant Design Vue组件使用演示</h1>
  31. <div class="text-foreground/80 mt-2">支持多语言,主题功能集成切换等</div>
  32. </div>
  33. <div class="card-box mt-5 p-5">
  34. <div class="mb-3">
  35. <span class="text-lg font-semibold">按钮</span>
  36. </div>
  37. <div>
  38. <Space>
  39. <Button>Default</Button>
  40. <Button type="primary"> Primary </Button>
  41. <Button> Info </Button>
  42. <Button danger> Error </Button>
  43. </Space>
  44. </div>
  45. </div>
  46. <div class="card-box mt-5 p-5">
  47. <div class="mb-3">
  48. <span class="text-lg font-semibold">卡片</span>
  49. </div>
  50. <div>
  51. <Card title="卡片"> 卡片内容 </Card>
  52. </div>
  53. </div>
  54. <div class="card-box mt-5 p-5">
  55. <div class="mb-3">
  56. <span class="text-lg font-semibold">信息 Message </span>
  57. </div>
  58. <div class="flex gap-3">
  59. <Button @click="info"> 信息 </Button>
  60. <Button danger @click="error"> 错误 </Button>
  61. <Button @click="warning"> 警告 </Button>
  62. <Button @click="success"> 成功 </Button>
  63. </div>
  64. </div>
  65. <div class="card-box mt-5 p-5">
  66. <div class="mb-3">
  67. <span class="text-lg font-semibold">通知 Notification </span>
  68. </div>
  69. <div class="flex gap-3">
  70. <Button @click="notify('info')"> 信息 </Button>
  71. <Button danger @click="notify('error')"> 错误 </Button>
  72. <Button @click="notify('warning')"> 警告 </Button>
  73. <Button @click="notify('success')"> 成功 </Button>
  74. </div>
  75. </div>
  76. </div>
  77. </template>