W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
將信息聚合在卡片容器中展示。
包含標(biāo)題,內(nèi)容和操作。
Card 組件包括header和body部分,header部分需要有顯式具名 slot 分發(fā),同時(shí)也是可選的。
<template>
<el-card class="box-card">
<template #header>
<div class="card-header">
<span>卡片名稱</span>
<el-button class="button" type="text">操作按鈕</el-button>
</div>
</template>
<div v-for="o in 4" :key="o" class="text item">{{'列表內(nèi)容 ' + o }}</div>
</el-card>
</template>
<style>
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.text {
font-size: 14px;
}
.item {
margin-bottom: 18px;
}
.box-card {
width: 480px;
}
</style>
卡片可以只有內(nèi)容區(qū)域。
<template>
<el-card class="box-card">
<div v-for="o in 4" :key="o" class="text item">{{'列表內(nèi)容 ' + o }}</div>
</el-card>
</template>
<style>
.text {
font-size: 14px;
}
.item {
padding: 18px 0;
}
.box-card {
width: 480px;
}
</style>
可配置定義更豐富的內(nèi)容展示。
配置body-style屬性來(lái)自定義body部分的style,我們還使用了布局組件。
<template>
<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" rel="external nofollow"
class="image"
/>
<div style="padding: 14px;">
<span>好吃的漢堡</span>
<div class="bottom">
<time class="time">{{ currentDate }}</time>
<el-button type="text" class="button">操作按鈕</el-button>
</div>
</div>
</el-card>
</el-col>
</el-row>
</template>
<script>
export default {
data() {
return {
currentDate: new Date(),
}
},
}
</script>
<style>
.time {
font-size: 13px;
color: #999;
}
.bottom {
margin-top: 13px;
line-height: 12px;
display: flex;
justify-content: space-between;
align-items: center;
}
.button {
padding: 0;
min-height: auto;
}
.image {
width: 100%;
display: block;
}
</style>
可對(duì)陰影的顯示進(jìn)行配置。
通過(guò)shadow屬性設(shè)置卡片陰影出現(xiàn)的時(shí)機(jī):always、hover或never。
<template>
<el-row :gutter="12">
<el-col :span="8">
<el-card shadow="always"> 總是顯示 </el-card>
</el-col>
<el-col :span="8">
<el-card shadow="hover"> 鼠標(biāo)懸浮時(shí)顯示 </el-card>
</el-col>
<el-col :span="8">
<el-card shadow="never"> 從不顯示 </el-card>
</el-col>
</el-row>
</template>
參數(shù) | 說(shuō)明 | 類型 | 可選值 | 默認(rèn)值 |
---|---|---|---|---|
header | 設(shè)置 header,也可以通過(guò) slot#header 傳入 DOM | string | — | — |
body-style | 設(shè)置 body 的樣式 | object | — | { padding: '20px' } |
shadow | 設(shè)置陰影顯示時(shí)機(jī) | string | always / hover / never | always |
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: