Descriptions 描述列表

列表形式展示多个字段。

基础用法

Descriptions 描述列表 - 图1

  1. <template>
  2. <el-descriptions title="User Info">
  3. <el-descriptions-item label="Username">kooriookami</el-descriptions-item>
  4. <el-descriptions-item label="Telephone">18100000000</el-descriptions-item>
  5. <el-descriptions-item label="Place">Suzhou</el-descriptions-item>
  6. <el-descriptions-item label="Remarks">
  7. <el-tag size="small">School</el-tag>
  8. </el-descriptions-item>
  9. <el-descriptions-item label="Address"
  10. >No.1188, Wuzhong Avenue, Wuzhong District, Suzhou, Jiangsu
  11. Province</el-descriptions-item
  12. >
  13. </el-descriptions>
  14. </template>

不同尺寸

Descriptions 描述列表 - 图2

  1. <template>
  2. <el-radio-group v-model="size">
  3. <el-radio label="large">Large</el-radio>
  4. <el-radio>Default</el-radio>
  5. <el-radio label="small">Small</el-radio>
  6. </el-radio-group>
  7. <el-descriptions
  8. class="margin-top"
  9. title="With border"
  10. :column="3"
  11. :size="size"
  12. border
  13. >
  14. <template #extra>
  15. <el-button type="primary">Operation</el-button>
  16. </template>
  17. <el-descriptions-item>
  18. <template #label>
  19. <div class="cell-item">
  20. <el-icon :style="iconStyle">
  21. <user />
  22. </el-icon>
  23. Username
  24. </div>
  25. </template>
  26. kooriookami
  27. </el-descriptions-item>
  28. <el-descriptions-item>
  29. <template #label>
  30. <div class="cell-item">
  31. <el-icon :style="iconStyle">
  32. <iphone />
  33. </el-icon>
  34. Telephone
  35. </div>
  36. </template>
  37. 18100000000
  38. </el-descriptions-item>
  39. <el-descriptions-item>
  40. <template #label>
  41. <div class="cell-item">
  42. <el-icon :style="iconStyle">
  43. <location />
  44. </el-icon>
  45. Place
  46. </div>
  47. </template>
  48. Suzhou
  49. </el-descriptions-item>
  50. <el-descriptions-item>
  51. <template #label>
  52. <div class="cell-item">
  53. <el-icon :style="iconStyle">
  54. <tickets />
  55. </el-icon>
  56. Remarks
  57. </div>
  58. </template>
  59. <el-tag size="small">School</el-tag>
  60. </el-descriptions-item>
  61. <el-descriptions-item>
  62. <template #label>
  63. <div class="cell-item">
  64. <el-icon :style="iconStyle">
  65. <office-building />
  66. </el-icon>
  67. Address
  68. </div>
  69. </template>
  70. No.1188, Wuzhong Avenue, Wuzhong District, Suzhou, Jiangsu Province
  71. </el-descriptions-item>
  72. </el-descriptions>
  73. <el-descriptions
  74. class="margin-top"
  75. title="Without border"
  76. :column="3"
  77. :size="size"
  78. :style="blockMargin"
  79. >
  80. <template #extra>
  81. <el-button type="primary">Operation</el-button>
  82. </template>
  83. <el-descriptions-item label="Username">kooriookami</el-descriptions-item>
  84. <el-descriptions-item label="Telephone">18100000000</el-descriptions-item>
  85. <el-descriptions-item label="Place">Suzhou</el-descriptions-item>
  86. <el-descriptions-item label="Remarks">
  87. <el-tag size="small">School</el-tag>
  88. </el-descriptions-item>
  89. <el-descriptions-item label="Address"
  90. >No.1188, Wuzhong Avenue, Wuzhong District, Suzhou, Jiangsu Province
  91. </el-descriptions-item>
  92. </el-descriptions>
  93. </template>
  94. <script setup lang="ts">
  95. import { computed, ref } from 'vue'
  96. import {
  97. Iphone,
  98. Location,
  99. OfficeBuilding,
  100. Tickets,
  101. User,
  102. } from '@element-plus/icons-vue'
  103. const size = ref('')
  104. const iconStyle = computed(() => {
  105. const marginMap = {
  106. large: '8px',
  107. default: '6px',
  108. small: '4px',
  109. }
  110. return {
  111. marginRight: marginMap[size.value] || marginMap.default,
  112. }
  113. })
  114. const blockMargin = computed(() => {
  115. const marginMap = {
  116. large: '32px',
  117. default: '28px',
  118. small: '24px',
  119. }
  120. return {
  121. marginTop: marginMap[size.value] || marginMap.default,
  122. }
  123. })
  124. </script>
  125. <style scoped>
  126. .el-descriptions {
  127. margin-top: 20px;
  128. }
  129. .cell-item {
  130. display: flex;
  131. align-items: center;
  132. }
  133. .margin-top {
  134. margin-top: 20px;
  135. }
  136. </style>

垂直列表

Descriptions 描述列表 - 图3

  1. <template>
  2. <el-radio-group v-model="size">
  3. <el-radio label="large">Large</el-radio>
  4. <el-radio>Default</el-radio>
  5. <el-radio label="small">Small</el-radio>
  6. </el-radio-group>
  7. <el-descriptions
  8. title="Vertical list with border"
  9. direction="vertical"
  10. :column="4"
  11. :size="size"
  12. border
  13. >
  14. <el-descriptions-item label="Username">kooriookami</el-descriptions-item>
  15. <el-descriptions-item label="Telephone">18100000000</el-descriptions-item>
  16. <el-descriptions-item label="Place" :span="2">Suzhou</el-descriptions-item>
  17. <el-descriptions-item label="Remarks">
  18. <el-tag size="small">School</el-tag>
  19. </el-descriptions-item>
  20. <el-descriptions-item label="Address"
  21. >No.1188, Wuzhong Avenue, Wuzhong District, Suzhou, Jiangsu Province
  22. </el-descriptions-item>
  23. </el-descriptions>
  24. <el-descriptions
  25. title="Vertical list without border"
  26. :column="4"
  27. :size="size"
  28. direction="vertical"
  29. :style="blockMargin"
  30. >
  31. <el-descriptions-item label="Username">kooriookami</el-descriptions-item>
  32. <el-descriptions-item label="Telephone">18100000000</el-descriptions-item>
  33. <el-descriptions-item label="Place" :span="2">Suzhou</el-descriptions-item>
  34. <el-descriptions-item label="Remarks">
  35. <el-tag size="small">School</el-tag>
  36. </el-descriptions-item>
  37. <el-descriptions-item label="Address"
  38. >No.1188, Wuzhong Avenue, Wuzhong District, Suzhou, Jiangsu Province
  39. </el-descriptions-item>
  40. </el-descriptions>
  41. </template>
  42. <script setup lang="ts">
  43. import { computed, ref } from 'vue'
  44. const size = ref('')
  45. const blockMargin = computed(() => {
  46. const marginMap = {
  47. large: '32px',
  48. default: '28px',
  49. small: '24px',
  50. }
  51. return {
  52. marginTop: marginMap[size.value] || marginMap.default,
  53. }
  54. })
  55. </script>
  56. <style scoped>
  57. .el-descriptions {
  58. margin-top: 20px;
  59. }
  60. </style>

自定义样式

Descriptions 描述列表 - 图4

  1. <template>
  2. <el-descriptions title="Customized style list" :column="3" border>
  3. <el-descriptions-item
  4. label="Username"
  5. label-align="right"
  6. align="center"
  7. label-class-name="my-label"
  8. class-name="my-content"
  9. width="150px"
  10. >kooriookami</el-descriptions-item
  11. >
  12. <el-descriptions-item label="Telephone" label-align="right" align="center"
  13. >18100000000</el-descriptions-item
  14. >
  15. <el-descriptions-item label="Place" label-align="right" align="center"
  16. >Suzhou</el-descriptions-item
  17. >
  18. <el-descriptions-item label="Remarks" label-align="right" align="center">
  19. <el-tag size="small">School</el-tag>
  20. </el-descriptions-item>
  21. <el-descriptions-item label="Address" label-align="right" align="center"
  22. >No.1188, Wuzhong Avenue, Wuzhong District, Suzhou, Jiangsu
  23. Province</el-descriptions-item
  24. >
  25. </el-descriptions>
  26. </template>
  27. <style scoped>
  28. .my-label {
  29. background: var(--el-color-success-light-9);
  30. }
  31. .my-content {
  32. background: var(--el-color-danger-light-9);
  33. }
  34. </style>

Descriptions 属性

属性说明类型可选值默认值
border是否带有边框booleanfalse
column一行 Descriptions Item 的数量number3
direction排列的方向stringvertical / horizontalhorizontal
size列表的尺寸stringlarge / default / smalldefault
title标题文本,显示在左上方string
extra操作区文本,显示在右上方string

Descriptions 插槽

插槽名说明子标签
自定义默认内容Descriptions Item
title自定义标题,显示在左上方
extra自定义操作区,显示在右上方

Descriptions Item 属性

属性说明类型可选值默认值
label标签文本string
span列的数量number1
width列的宽度,不同行相同列的宽度按最大值设定(如无 border ,宽度包含标签与内容)string / number
min-width列的最小宽度,与 width 的区别是 width 是固定的,min-width 会把剩余宽度按比例分配给设置了 min-width 的列(如无 border,宽度包含标签与内容)string / number
align列的内容对齐方式(如无 border,对标签和内容均生效)stringleft / center / rightleft
label-align列的标签对齐方式,若不设置该项,则使用内容的对齐方式(如无 border,请使用 align 参数)stringleft / center / right
class-name列的内容自定义类名string
label-class-namecolumn label custom class namestring

Descriptions Item 插槽

插槽名说明
自定义默认内容
label自定义标签

源代码

组件 Descriptions 描述列表 - 图5 文档 Descriptions 描述列表 - 图6

贡献者

Descriptions 描述列表 - 图7 云游君

Descriptions 描述列表 - 图8 三咲智子

Descriptions 描述列表 - 图9 jeremywu

Descriptions 描述列表 - 图10 kooriookami

Descriptions 描述列表 - 图11 Aex

Descriptions 描述列表 - 图12 류한경

Descriptions 描述列表 - 图13 Delyan Haralanov

Descriptions 描述列表 - 图14 btea

Descriptions 描述列表 - 图15 Herrington Darkholme

Descriptions 描述列表 - 图16 C.Y.Kun

Descriptions 描述列表 - 图17 qiang