2020-08-13 15:18:26 +08:00
|
|
|
## Card
|
|
|
|
|
|
|
|
Conteneur intégrant des informations.
|
|
|
|
|
|
|
|
### Usage
|
|
|
|
|
|
|
|
Le composant Card comprend un titre, un contenu et des opérations.
|
|
|
|
|
|
|
|
:::demo Card est composé d'un `header` et d'un `body`. `header` est optionnel et son contenu nécessite l'utilisation d'un slot.
|
2021-09-04 19:29:28 +08:00
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
```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>Card name</span>
|
2021-02-01 14:48:26 +08:00
|
|
|
<el-button class="button" type="text">Bouton</el-button>
|
2020-11-29 18:50:46 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
2021-09-04 19:29:28 +08:00
|
|
|
<div v-for="o in 4" :key="o" class="text item">{{'List item ' + o }}</div>
|
2020-08-13 15:18:26 +08:00
|
|
|
</el-card>
|
|
|
|
|
|
|
|
<style>
|
2021-02-01 14:48:26 +08:00
|
|
|
.card-header {
|
2021-09-04 19:29:28 +08:00
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
2021-02-01 14:48:26 +08:00
|
|
|
}
|
2021-09-04 19:29:28 +08:00
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
.text {
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.item {
|
|
|
|
margin-bottom: 18px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.box-card {
|
|
|
|
width: 480px;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
```
|
2021-09-04 19:29:28 +08:00
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
:::
|
|
|
|
|
|
|
|
### Card simple
|
|
|
|
|
|
|
|
Le header peut être omis.
|
|
|
|
|
|
|
|
:::demo
|
2021-09-04 19:29:28 +08:00
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
```html
|
|
|
|
<el-card class="box-card">
|
2021-09-04 19:29:28 +08:00
|
|
|
<div v-for="o in 4" :key="o" class="text item">{{'List item ' + o }}</div>
|
2020-08-13 15:18:26 +08:00
|
|
|
</el-card>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.text {
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.item {
|
|
|
|
padding: 18px 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.box-card {
|
|
|
|
width: 480px;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
```
|
2021-09-04 19:29:28 +08:00
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
:::
|
|
|
|
|
|
|
|
### Images
|
|
|
|
|
|
|
|
Affichez un contenu plus riche grâce à la configuration.
|
|
|
|
|
|
|
|
:::demo L'attribut `body-style` définit le style CSS du `body`. Cet exemple utilise aussi `el-col` pour la mise en page.
|
2021-09-04 19:29:28 +08:00
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
```html
|
|
|
|
<el-row>
|
2021-09-04 19:29:28 +08:00
|
|
|
<el-col
|
|
|
|
:span="8"
|
|
|
|
v-for="(o, index) in 2"
|
|
|
|
:key="o"
|
|
|
|
:offset="index > 0 ? 2 : 0"
|
|
|
|
>
|
2020-08-13 15:18:26 +08:00
|
|
|
<el-card :body-style="{ padding: '0px' }">
|
2021-09-04 19:29:28 +08:00
|
|
|
<img
|
|
|
|
src="https://shadow.elemecdn.com/app/element/hamburger.9cf7b091-55e9-11e9-a976-7f4d0b07eef6.png"
|
|
|
|
class="image"
|
|
|
|
/>
|
2020-08-13 15:18:26 +08:00
|
|
|
<div style="padding: 14px;">
|
|
|
|
<span>Yummy hamburger</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">Operating</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>
|
2021-09-04 19:29:28 +08:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
currentDate: new Date(),
|
|
|
|
}
|
|
|
|
},
|
2020-08-13 15:18:26 +08:00
|
|
|
}
|
|
|
|
</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
|
|
|
```
|
2021-09-04 19:29:28 +08:00
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
:::
|
|
|
|
|
|
|
|
### Ombres
|
|
|
|
|
|
|
|
Vous pouvez définir quand l'ombre des Cards doivent apparaître.
|
|
|
|
|
|
|
|
:::demo L'attribut `shadow` détermine quand l'ombre doit apparaître. Les valeurs possibles sont `always`, `hover` ou `never`.
|
2021-09-04 19:29:28 +08:00
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
```html
|
|
|
|
<el-row :gutter="12">
|
|
|
|
<el-col :span="8">
|
2021-09-04 19:29:28 +08:00
|
|
|
<el-card shadow="always"> Always </el-card>
|
2020-08-13 15:18:26 +08:00
|
|
|
</el-col>
|
|
|
|
<el-col :span="8">
|
2021-09-04 19:29:28 +08:00
|
|
|
<el-card shadow="hover"> Hover </el-card>
|
2020-08-13 15:18:26 +08:00
|
|
|
</el-col>
|
|
|
|
<el-col :span="8">
|
2021-09-04 19:29:28 +08:00
|
|
|
<el-card shadow="never"> Never </el-card>
|
2020-08-13 15:18:26 +08:00
|
|
|
</el-col>
|
|
|
|
</el-row>
|
|
|
|
```
|
2021-09-04 19:29:28 +08:00
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
:::
|
|
|
|
|
|
|
|
### Attributs
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
|
|
| Attribut | Description | Type | Valeurs acceptées | Défaut |
|
|
|
|
| ---------- | ------------------------------------------------------------------------ | ------ | ---------------------- | ------------------- |
|
|
|
|
| header | Titre de la Card. Accepte aussi un template DOM passé via `slot#header`. | string | — | — |
|
|
|
|
| body-style | Style CSS du body. | object | — | { padding: '20px' } |
|
|
|
|
| shadow | Quand l'ombre doit apparaître | string | always / hover / never | always |
|