element/examples/docs/card.md

133 lines
2.8 KiB
Markdown
Raw Normal View History

2016-08-16 18:51:53 +08:00
<script>
import dateUtil from 'main/utils/date'
2016-08-16 18:51:53 +08:00
export default {
data() {
return {
currentDate: dateUtil.format(new Date(), 'yyyy-MM-dd HH:mm')
2016-08-16 18:51:53 +08:00
};
}
}
</script>
<style scoped>
.text {
font-size: 14px;
}
.time {
font-size: 13px;
color: #999;
}
.bottom {
2016-08-16 18:51:53 +08:00
margin-top: 13px;
line-height: 12px;
2016-08-16 18:51:53 +08:00
}
.item {
padding: 18px 0;
}
.button {
padding: 0;
float: right;
}
.image {
width: 100%;
display: block;
}
.clearfix {
@utils-clearfix;
2016-08-16 18:51:53 +08:00
}
</style>
## 基础用法
包含标题, 内容和操作
<el-row>
<el-col :span="12">
<el-card>
<div slot="header" class="clearfix">
<span style="line-height: 36px;">卡片名称</span>
<el-button style="float: right;" type="primary">操作按钮</el-button>
2016-08-16 18:51:53 +08:00
</div>
<div v-for="o in 4" class="text item">
{{'列表内容 ' + o }}
</div>
</el-card>
</el-col>
</el-row>
```html
<el-card>
<div slot="header" class="clearfix">
<span style="line-height: 36px;">卡片名称</span>
<el-button style="float: right;" type="primary">操作按钮</el-button>
2016-08-16 18:51:53 +08:00
</div>
<div v-for="o in 4" class="text item">
{{'列表内容 ' + o }}
</div>
</el-card>
```
## 简单卡片
卡片可以只有内容区域
<el-row>
<el-col :span="12">
<el-card>
<div v-for="o in 4" class="text item">
{{'列表内容 ' + o }}
</div>
</el-card>
</el-col>
</el-row>
```html
<el-card>
<div v-for="o in 4" class="text item">
{{'列表内容 ' + o }}
</div>
</el-card>
```
## 带图片
可配置定义更丰富的内容展示
<el-row>
<el-col :span="8" v-for="(o, index) in 2" :offset="index > 0 ? 2 : 0">
<el-card :body-style="{ padding: '0px' }">
<img src="~examples/assets/images/hamburger.png" class="image">
<div style="padding: 14px;">
<span>好吃的汉堡</span>
<div class="bottom clearfix">
2016-08-16 18:51:53 +08:00
<time class="time">{{ currentDate }}</time>
<el-button type="text" class="button">操作按钮</el-button>
2016-08-16 18:51:53 +08:00
</div>
</div>
</el-card>
</el-col>
</el-row>
```html
<el-card :body-style="{ padding: '0px' }">
<img src="~examples/assets/images/hamburger.png" class="image">
<div style="padding: 14px;">
<span>好吃的汉堡</span>
<div class="bottom clearfix">
2016-08-16 18:51:53 +08:00
<time class="time">{{ currentDate }}</time>
<el-button type="text" class="button">操作按钮</el-button>
2016-08-16 18:51:53 +08:00
</div>
</div>
</el-card>
```
## API
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| header | 设置 header也可以通过 `slot#header` 传入 DOM | string| | |
| body-style | 设置 body 的样式| object| | { padding: '20px' } |