Descriptions 描述列表
列表形式展示多个字段。
基础用法
<template>
<el-descriptions title="User Info">
<el-descriptions-item label="Username">kooriookami</el-descriptions-item>
<el-descriptions-item label="Telephone">18100000000</el-descriptions-item>
<el-descriptions-item label="Place">Suzhou</el-descriptions-item>
<el-descriptions-item label="Remarks">
<el-tag size="small">School</el-tag>
</el-descriptions-item>
<el-descriptions-item label="Address"
>No.1188, Wuzhong Avenue, Wuzhong District, Suzhou, Jiangsu
Province</el-descriptions-item
>
</el-descriptions>
</template>
不同尺寸
<template>
<el-radio-group v-model="size">
<el-radio label="large">Large</el-radio>
<el-radio>Default</el-radio>
<el-radio label="small">Small</el-radio>
</el-radio-group>
<el-descriptions
class="margin-top"
title="With border"
:column="3"
:size="size"
border
>
<template #extra>
<el-button type="primary">Operation</el-button>
</template>
<el-descriptions-item>
<template #label>
<div class="cell-item">
<el-icon :style="iconStyle">
<user />
</el-icon>
Username
</div>
</template>
kooriookami
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item">
<el-icon :style="iconStyle">
<iphone />
</el-icon>
Telephone
</div>
</template>
18100000000
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item">
<el-icon :style="iconStyle">
<location />
</el-icon>
Place
</div>
</template>
Suzhou
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item">
<el-icon :style="iconStyle">
<tickets />
</el-icon>
Remarks
</div>
</template>
<el-tag size="small">School</el-tag>
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item">
<el-icon :style="iconStyle">
<office-building />
</el-icon>
Address
</div>
</template>
No.1188, Wuzhong Avenue, Wuzhong District, Suzhou, Jiangsu Province
</el-descriptions-item>
</el-descriptions>
<el-descriptions
class="margin-top"
title="Without border"
:column="3"
:size="size"
:style="blockMargin"
>
<template #extra>
<el-button type="primary">Operation</el-button>
</template>
<el-descriptions-item label="Username">kooriookami</el-descriptions-item>
<el-descriptions-item label="Telephone">18100000000</el-descriptions-item>
<el-descriptions-item label="Place">Suzhou</el-descriptions-item>
<el-descriptions-item label="Remarks">
<el-tag size="small">School</el-tag>
</el-descriptions-item>
<el-descriptions-item label="Address"
>No.1188, Wuzhong Avenue, Wuzhong District, Suzhou, Jiangsu Province
</el-descriptions-item>
</el-descriptions>
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
import {
Iphone,
Location,
OfficeBuilding,
Tickets,
User,
} from '@element-plus/icons-vue'
const size = ref('')
const iconStyle = computed(() => {
const marginMap = {
large: '8px',
default: '6px',
small: '4px',
}
return {
marginRight: marginMap[size.value] || marginMap.default,
}
})
const blockMargin = computed(() => {
const marginMap = {
large: '32px',
default: '28px',
small: '24px',
}
return {
marginTop: marginMap[size.value] || marginMap.default,
}
})
</script>
<style scoped>
.el-descriptions {
margin-top: 20px;
}
.cell-item {
display: flex;
align-items: center;
}
.margin-top {
margin-top: 20px;
}
</style>
垂直列表
<template>
<el-radio-group v-model="size">
<el-radio label="large">Large</el-radio>
<el-radio>Default</el-radio>
<el-radio label="small">Small</el-radio>
</el-radio-group>
<el-descriptions
title="Vertical list with border"
direction="vertical"
:column="4"
:size="size"
border
>
<el-descriptions-item label="Username">kooriookami</el-descriptions-item>
<el-descriptions-item label="Telephone">18100000000</el-descriptions-item>
<el-descriptions-item label="Place" :span="2">Suzhou</el-descriptions-item>
<el-descriptions-item label="Remarks">
<el-tag size="small">School</el-tag>
</el-descriptions-item>
<el-descriptions-item label="Address"
>No.1188, Wuzhong Avenue, Wuzhong District, Suzhou, Jiangsu Province
</el-descriptions-item>
</el-descriptions>
<el-descriptions
title="Vertical list without border"
:column="4"
:size="size"
direction="vertical"
:style="blockMargin"
>
<el-descriptions-item label="Username">kooriookami</el-descriptions-item>
<el-descriptions-item label="Telephone">18100000000</el-descriptions-item>
<el-descriptions-item label="Place" :span="2">Suzhou</el-descriptions-item>
<el-descriptions-item label="Remarks">
<el-tag size="small">School</el-tag>
</el-descriptions-item>
<el-descriptions-item label="Address"
>No.1188, Wuzhong Avenue, Wuzhong District, Suzhou, Jiangsu Province
</el-descriptions-item>
</el-descriptions>
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
const size = ref('')
const blockMargin = computed(() => {
const marginMap = {
large: '32px',
default: '28px',
small: '24px',
}
return {
marginTop: marginMap[size.value] || marginMap.default,
}
})
</script>
<style scoped>
.el-descriptions {
margin-top: 20px;
}
</style>
自定义样式
<template>
<el-descriptions title="Customized style list" :column="3" border>
<el-descriptions-item
label="Username"
label-align="right"
align="center"
label-class-name="my-label"
class-name="my-content"
width="150px"
>kooriookami</el-descriptions-item
>
<el-descriptions-item label="Telephone" label-align="right" align="center"
>18100000000</el-descriptions-item
>
<el-descriptions-item label="Place" label-align="right" align="center"
>Suzhou</el-descriptions-item
>
<el-descriptions-item label="Remarks" label-align="right" align="center">
<el-tag size="small">School</el-tag>
</el-descriptions-item>
<el-descriptions-item label="Address" label-align="right" align="center"
>No.1188, Wuzhong Avenue, Wuzhong District, Suzhou, Jiangsu
Province</el-descriptions-item
>
</el-descriptions>
</template>
<style scoped>
.my-label {
background: var(--el-color-success-light-9);
}
.my-content {
background: var(--el-color-danger-light-9);
}
</style>
Descriptions 属性
属性 | 说明 | 类型 | 可选值 | 默认值 |
---|
border | 是否带有边框 | boolean | — | false |
column | 一行 Descriptions Item 的数量 | number | — | 3 |
direction | 排列的方向 | string | vertical / horizontal | horizontal |
size | 列表的尺寸 | string | large / default / small | default |
title | 标题文本,显示在左上方 | string | — | — |
extra | 操作区文本,显示在右上方 | string | — | — |
Descriptions 插槽
插槽名 | 说明 | 子标签 |
---|
— | 自定义默认内容 | Descriptions Item |
title | 自定义标题,显示在左上方 | — |
extra | 自定义操作区,显示在右上方 | — |
Descriptions Item 属性
属性 | 说明 | 类型 | 可选值 | 默认值 |
---|
label | 标签文本 | string | — | — |
span | 列的数量 | number | — | 1 |
width | 列的宽度,不同行相同列的宽度按最大值设定(如无 border ,宽度包含标签与内容) | string / number | — | — |
min-width | 列的最小宽度,与 width 的区别是 width 是固定的,min-width 会把剩余宽度按比例分配给设置了 min-width 的列(如无 border ,宽度包含标签与内容) | string / number | — | — |
align | 列的内容对齐方式(如无 border ,对标签和内容均生效) | string | left / center / right | left |
label-align | 列的标签对齐方式,若不设置该项,则使用内容的对齐方式(如无 border ,请使用 align 参数) | string | left / center / right | — |
class-name | 列的内容自定义类名 | string | — | — |
label-class-name | column label custom class name | string | — | — |
Descriptions Item 插槽
源代码
组件 • 文档
贡献者
云游君
三咲智子
jeremywu
kooriookami
Aex
류한경
Delyan Haralanov
btea
Herrington Darkholme
C.Y.Kun
qiang