2016-08-16 18:51:53 +08:00
|
|
|
|
<script>
|
2016-08-17 11:11:54 +08:00
|
|
|
|
import dateUtil from 'main/utils/date'
|
2016-08-16 18:51:53 +08:00
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2016-08-17 11:11:54 +08:00
|
|
|
|
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;
|
2016-08-17 11:11:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.bottom {
|
2016-08-16 18:51:53 +08:00
|
|
|
|
margin-top: 13px;
|
2016-08-17 11:11:54 +08:00
|
|
|
|
line-height: 12px;
|
2016-08-16 18:51:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.item {
|
|
|
|
|
padding: 18px 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.button {
|
|
|
|
|
padding: 0;
|
2016-08-17 11:11:54 +08:00
|
|
|
|
float: right;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.image {
|
|
|
|
|
width: 100%;
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.clearfix {
|
|
|
|
|
@utils-clearfix;
|
2016-08-16 18:51:53 +08:00
|
|
|
|
}
|
|
|
|
|
</style>
|
2016-08-26 18:34:54 +08:00
|
|
|
|
## Card 卡片
|
|
|
|
|
将信息聚合在卡片容器中展示
|
2016-08-16 18:51:53 +08:00
|
|
|
|
|
2016-08-26 18:34:54 +08:00
|
|
|
|
### 基础用法
|
2016-08-18 17:29:11 +08:00
|
|
|
|
|
|
|
|
|
|
2016-08-25 18:24:51 +08:00
|
|
|
|
下面是一个带有标题、内容和操作(按钮)的 Card 组件示例,需要注意的是,部分样式需要你自己填入。
|
2016-08-16 18:51:53 +08:00
|
|
|
|
|
2016-08-25 18:24:51 +08:00
|
|
|
|
:::demo Card 组件包括`header`和`body`部分,`header`部分需要有显式具名 slot 分发,同时也是可选的。
|
2016-08-16 18:51:53 +08:00
|
|
|
|
```html
|
|
|
|
|
<el-card>
|
2016-08-17 11:11:54 +08:00
|
|
|
|
<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>
|
|
|
|
|
```
|
2016-08-25 18:24:51 +08:00
|
|
|
|
:::
|
2016-08-16 18:51:53 +08:00
|
|
|
|
|
2016-08-26 18:34:54 +08:00
|
|
|
|
### 简单卡片
|
2016-08-18 17:29:11 +08:00
|
|
|
|
|
2016-08-25 18:24:51 +08:00
|
|
|
|
卡片可以只有内容区域。
|
2016-08-16 18:51:53 +08:00
|
|
|
|
|
2016-08-25 18:24:51 +08:00
|
|
|
|
:::demo
|
2016-08-16 18:51:53 +08:00
|
|
|
|
```html
|
|
|
|
|
<el-card>
|
|
|
|
|
<div v-for="o in 4" class="text item">
|
|
|
|
|
{{'列表内容 ' + o }}
|
|
|
|
|
</div>
|
|
|
|
|
</el-card>
|
|
|
|
|
```
|
2016-08-25 18:24:51 +08:00
|
|
|
|
:::
|
2016-08-16 18:51:53 +08:00
|
|
|
|
|
2016-08-26 18:34:54 +08:00
|
|
|
|
### 进阶使用
|
2016-08-25 18:24:51 +08:00
|
|
|
|
可以让你的卡片极大程度的被个性化,为更丰富的内容展示服务。
|
2016-08-18 17:29:11 +08:00
|
|
|
|
|
|
|
|
|
下例是一个带图片的示例,能帮助你更好地理解`body-style`配合分发内容自定义样式的强大:
|
2016-08-16 18:51:53 +08:00
|
|
|
|
|
2016-08-25 18:24:51 +08:00
|
|
|
|
:::demo 配置`body-style`属性来自定义`body`部分的`style`,我们还使用了布局组件。
|
|
|
|
|
```html
|
2016-08-16 18:51:53 +08:00
|
|
|
|
<el-row>
|
|
|
|
|
<el-col :span="8" v-for="(o, index) in 2" :offset="index > 0 ? 2 : 0">
|
|
|
|
|
<el-card :body-style="{ padding: '0px' }">
|
2016-08-17 11:11:54 +08:00
|
|
|
|
<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>
|
2016-08-17 11:11:54 +08:00
|
|
|
|
<el-button type="text" class="button">操作按钮</el-button>
|
2016-08-16 18:51:53 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</el-card>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
```
|
2016-08-25 18:24:51 +08:00
|
|
|
|
:::
|
2016-08-16 18:51:53 +08:00
|
|
|
|
|
2016-08-26 18:34:54 +08:00
|
|
|
|
### Attributes
|
2016-08-16 18:51:53 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
|
|
|
|---------- |-------- |---------- |------------- |-------- |
|
|
|
|
|
| header | 设置 header,也可以通过 `slot#header` 传入 DOM | string| | |
|
|
|
|
|
| body-style | 设置 body 的样式| object| | { padding: '20px' } |
|