2020-08-13 15:18:26 +08:00
|
|
|
|
## Card 卡片
|
|
|
|
|
将信息聚合在卡片容器中展示。
|
|
|
|
|
|
|
|
|
|
### 基础用法
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
包含标题,内容和操作。
|
|
|
|
|
|
|
|
|
|
:::demo Card 组件包括`header`和`body`部分,`header`部分需要有显式具名 slot 分发,同时也是可选的。
|
|
|
|
|
```html
|
|
|
|
|
<el-card class="box-card">
|
2020-11-29 18:50:46 +08:00
|
|
|
|
<template #header>
|
2021-02-01 14:48:26 +08:00
|
|
|
|
<div class="card-header">
|
2020-11-29 18:50:46 +08:00
|
|
|
|
<span>卡片名称</span>
|
2021-02-01 14:48:26 +08:00
|
|
|
|
<el-button class="button" type="text">操作按钮</el-button>
|
2020-11-29 18:50:46 +08:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
2020-08-13 15:18:26 +08:00
|
|
|
|
<div v-for="o in 4" :key="o" class="text item">
|
|
|
|
|
{{'列表内容 ' + o }}
|
|
|
|
|
</div>
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
<style>
|
2021-02-01 14:48:26 +08:00
|
|
|
|
.card-header {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
|
.text {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.item {
|
|
|
|
|
margin-bottom: 18px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.box-card {
|
|
|
|
|
width: 480px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
```
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
### 简单卡片
|
|
|
|
|
|
|
|
|
|
卡片可以只有内容区域。
|
|
|
|
|
|
|
|
|
|
:::demo
|
|
|
|
|
```html
|
|
|
|
|
<el-card class="box-card">
|
|
|
|
|
<div v-for="o in 4" :key="o" class="text item">
|
|
|
|
|
{{'列表内容 ' + o }}
|
|
|
|
|
</div>
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.text {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.item {
|
|
|
|
|
padding: 18px 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.box-card {
|
|
|
|
|
width: 480px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
```
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
### 带图片
|
|
|
|
|
|
|
|
|
|
可配置定义更丰富的内容展示。
|
|
|
|
|
|
|
|
|
|
:::demo 配置`body-style`属性来自定义`body`部分的`style`,我们还使用了布局组件。
|
|
|
|
|
```html
|
|
|
|
|
<el-row>
|
|
|
|
|
<el-col :span="8" v-for="(o, index) in 2" :key="o" :offset="index > 0 ? 2 : 0">
|
|
|
|
|
<el-card :body-style="{ padding: '0px' }">
|
|
|
|
|
<img src="https://shadow.elemecdn.com/app/element/hamburger.9cf7b091-55e9-11e9-a976-7f4d0b07eef6.png" class="image">
|
|
|
|
|
<div style="padding: 14px;">
|
|
|
|
|
<span>好吃的汉堡</span>
|
2021-02-01 14:48:26 +08:00
|
|
|
|
<div class="bottom">
|
2020-08-13 15:18:26 +08:00
|
|
|
|
<time class="time">{{ currentDate }}</time>
|
|
|
|
|
<el-button type="text" class="button">操作按钮</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</el-card>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.time {
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
color: #999;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.bottom {
|
|
|
|
|
margin-top: 13px;
|
|
|
|
|
line-height: 12px;
|
2021-02-01 14:48:26 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
2020-08-13 15:18:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.button {
|
|
|
|
|
padding: 0;
|
2021-02-01 14:48:26 +08:00
|
|
|
|
min-height: auto;
|
2020-08-13 15:18:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.image {
|
|
|
|
|
width: 100%;
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
currentDate: new Date()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
2021-06-08 13:34:45 +08:00
|
|
|
|
<!--
|
|
|
|
|
<setup>
|
|
|
|
|
|
|
|
|
|
import { defineComponent, ref } from 'vue';
|
|
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
|
setup() {
|
|
|
|
|
const currentDate = ref(new Date());
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
currentDate,
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
</setup>
|
|
|
|
|
-->
|
2020-08-13 15:18:26 +08:00
|
|
|
|
```
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
### 卡片阴影
|
|
|
|
|
|
|
|
|
|
可对阴影的显示进行配置。
|
|
|
|
|
|
|
|
|
|
:::demo 通过`shadow`属性设置卡片阴影出现的时机:`always`、`hover`或`never`。
|
|
|
|
|
```html
|
|
|
|
|
<el-row :gutter="12">
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-card shadow="always">
|
|
|
|
|
总是显示
|
|
|
|
|
</el-card>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-card shadow="hover">
|
|
|
|
|
鼠标悬浮时显示
|
|
|
|
|
</el-card>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-card shadow="never">
|
|
|
|
|
从不显示
|
|
|
|
|
</el-card>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
```
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
### Attributes
|
|
|
|
|
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
|
|
|
|---------- |-------- |---------- |------------- |-------- |
|
|
|
|
|
| header | 设置 header,也可以通过 `slot#header` 传入 DOM | string| — | — |
|
|
|
|
|
| body-style | 设置 body 的样式| object| — | { padding: '20px' } |
|
|
|
|
|
| shadow | 设置阴影显示时机 | string | always / hover / never | always |
|