index.vue 2.9 KB

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