index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <script lang="ts" setup>
  2. import { Page } from '@vben/common-ui';
  3. import {
  4. ElButton,
  5. ElCard,
  6. ElMessage,
  7. ElNotification,
  8. ElSpace,
  9. ElTable,
  10. } from 'element-plus';
  11. type NotificationType = 'error' | 'info' | 'success' | 'warning';
  12. function info() {
  13. ElMessage.info('How many roads must a man walk down');
  14. }
  15. function error() {
  16. ElMessage.error({
  17. duration: 2500,
  18. message: 'Once upon a time you dressed so fine',
  19. });
  20. }
  21. function warning() {
  22. ElMessage.warning('How many roads must a man walk down');
  23. }
  24. function success() {
  25. ElMessage.success(
  26. 'Cause you walked hand in hand With another man in my place',
  27. );
  28. }
  29. function notify(type: NotificationType) {
  30. ElNotification({
  31. duration: 2500,
  32. message: '说点啥呢',
  33. type,
  34. });
  35. }
  36. const tableData = [
  37. { prop1: '1', prop2: 'A' },
  38. { prop1: '2', prop2: 'B' },
  39. { prop1: '3', prop2: 'C' },
  40. { prop1: '4', prop2: 'D' },
  41. { prop1: '5', prop2: 'E' },
  42. { prop1: '6', prop2: 'F' },
  43. ];
  44. </script>
  45. <template>
  46. <Page
  47. description="支持多语言,主题功能集成切换等"
  48. title="Element Plus组件使用演示"
  49. >
  50. <ElCard class="mb-5">
  51. <template #header> 按钮 </template>
  52. <ElSpace>
  53. <ElButton>Default</ElButton>
  54. <ElButton type="primary"> Primary </ElButton>
  55. <ElButton type="info"> Info </ElButton>
  56. <ElButton type="success"> Success </ElButton>
  57. <ElButton type="warning"> Warning </ElButton>
  58. <ElButton type="danger"> Error </ElButton>
  59. </ElSpace>
  60. </ElCard>
  61. <ElCard class="mb-5">
  62. <template #header> Message </template>
  63. <ElSpace>
  64. <ElButton type="info" @click="info"> 信息 </ElButton>
  65. <ElButton type="danger" @click="error"> 错误 </ElButton>
  66. <ElButton type="warning" @click="warning"> 警告 </ElButton>
  67. <ElButton type="success" @click="success"> 成功 </ElButton>
  68. </ElSpace>
  69. </ElCard>
  70. <ElCard class="mb-5">
  71. <template #header> Notification </template>
  72. <ElSpace>
  73. <ElButton type="info" @click="notify('info')"> 信息 </ElButton>
  74. <ElButton type="danger" @click="notify('error')"> 错误 </ElButton>
  75. <ElButton type="warning" @click="notify('warning')"> 警告 </ElButton>
  76. <ElButton type="success" @click="notify('success')"> 成功 </ElButton>
  77. </ElSpace>
  78. </ElCard>
  79. <ElCard class="mb-5">
  80. <ElTable :data="tableData" stripe>
  81. <ElTable.TableColumn label="测试列1" prop="prop1" />
  82. <ElTable.TableColumn label="测试列2" prop="prop2" />
  83. </ElTable>
  84. </ElCard>
  85. </Page>
  86. </template>