|
| 1 | +<script> |
| 2 | + export default { |
| 3 | + methods: { |
| 4 | + hello() { |
| 5 | + alert('Hello World!'); |
| 6 | + } |
| 7 | + } |
| 8 | + } |
| 9 | +</script> |
| 10 | +<style> |
| 11 | + .demo-box.demo-alert .el-alert { |
| 12 | + margin: 20px 0 0; |
| 13 | + } |
| 14 | + |
| 15 | + .demo-box.demo-alert .el-alert:first-child { |
| 16 | + margin: 0; |
| 17 | + } |
| 18 | +</style> |
| 19 | + |
| 20 | +## Alerte |
| 21 | + |
| 22 | +Affiche des messages importants. |
| 23 | + |
| 24 | +### Usage |
| 25 | + |
| 26 | +Les Alertes sont des composants non-superposés qui ne disparaissent pas automatiquement. |
| 27 | + |
| 28 | +:::demo Les Alertes peuvent être de 4 types différents, définit par `type`, le type par défaut étant `info`. |
| 29 | + |
| 30 | +```html |
| 31 | +<template> |
| 32 | + <el-alert |
| 33 | + title="succès" |
| 34 | + type="success"> |
| 35 | + </el-alert> |
| 36 | + <el-alert |
| 37 | + title="information" |
| 38 | + type="info"> |
| 39 | + </el-alert> |
| 40 | + <el-alert |
| 41 | + title="avertissement" |
| 42 | + type="warning"> |
| 43 | + </el-alert> |
| 44 | + <el-alert |
| 45 | + title="erreur" |
| 46 | + type="error"> |
| 47 | + </el-alert> |
| 48 | +</template> |
| 49 | +``` |
| 50 | +::: |
| 51 | + |
| 52 | +### Bouton personnalisable |
| 53 | + |
| 54 | +Personnalisez le bouton de fermeture avec du texte ou des symboles. |
| 55 | + |
| 56 | +:::demo Les alertes peuvent être configurées pour être fermables ou non. Le bouton de fermeture et les callbacks sont aussi personnalisables. L'attribut `closable` détermine si le composant peut être fermé ou non. Il accepte un `boolean`, la valeur par défaut étant `true`. Vous pouvez configurer l'attribut `close-text`pour remplacer la croix du bouton de fermeture. Assurez-vous que `close-text` soit une chaîne de caractères. L'évènement `close` se déclenche quand le composant est fermé. |
| 57 | + |
| 58 | +```html |
| 59 | +<template> |
| 60 | + <el-alert |
| 61 | + title="alerte non-fermable" |
| 62 | + type="success" |
| 63 | + :closable="false"> |
| 64 | + </el-alert> |
| 65 | + <el-alert |
| 66 | + title="texte de fermeture personnalisé" |
| 67 | + type="info" |
| 68 | + close-text="Gotcha"> |
| 69 | + </el-alert> |
| 70 | + <el-alert |
| 71 | + title="alerte avec callback" |
| 72 | + type="warning" |
| 73 | + @close="hello"> |
| 74 | + </el-alert> |
| 75 | +</template> |
| 76 | + |
| 77 | +<script> |
| 78 | + export default { |
| 79 | + methods: { |
| 80 | + hello() { |
| 81 | + alert('Hello World!'); |
| 82 | + } |
| 83 | + } |
| 84 | + } |
| 85 | +</script> |
| 86 | +``` |
| 87 | +::: |
| 88 | + |
| 89 | +### Avec icône |
| 90 | + |
| 91 | +Afficher une icône améliore la lisibilité. |
| 92 | + |
| 93 | +:::demo Ajouter l'attribut `show-icon` affiche une icône correspondant au type de l'alerte. |
| 94 | + |
| 95 | +```html |
| 96 | +<template> |
| 97 | + <el-alert |
| 98 | + title="succès" |
| 99 | + type="success" |
| 100 | + show-icon> |
| 101 | + </el-alert> |
| 102 | + <el-alert |
| 103 | + title="information" |
| 104 | + type="info" |
| 105 | + show-icon> |
| 106 | + </el-alert> |
| 107 | + <el-alert |
| 108 | + title="avertissement" |
| 109 | + type="warning" |
| 110 | + show-icon> |
| 111 | + </el-alert> |
| 112 | + <el-alert |
| 113 | + title="erreur" |
| 114 | + type="error" |
| 115 | + show-icon> |
| 116 | + </el-alert> |
| 117 | +</template> |
| 118 | +``` |
| 119 | +::: |
| 120 | + |
| 121 | +## Texte centré |
| 122 | + |
| 123 | +Utilisez l'attribut `center` pour centrer le texte. |
| 124 | + |
| 125 | +:::demo |
| 126 | + |
| 127 | +```html |
| 128 | +<template> |
| 129 | + <el-alert |
| 130 | + title="succès" |
| 131 | + type="success" |
| 132 | + center |
| 133 | + show-icon> |
| 134 | + </el-alert> |
| 135 | + <el-alert |
| 136 | + title="information" |
| 137 | + type="info" |
| 138 | + center |
| 139 | + show-icon> |
| 140 | + </el-alert> |
| 141 | + <el-alert |
| 142 | + title="avertissement" |
| 143 | + type="warning" |
| 144 | + center |
| 145 | + show-icon> |
| 146 | + </el-alert> |
| 147 | + <el-alert |
| 148 | + title="erreur" |
| 149 | + type="error" |
| 150 | + center |
| 151 | + show-icon> |
| 152 | + </el-alert> |
| 153 | +</template> |
| 154 | +``` |
| 155 | +::: |
| 156 | + |
| 157 | +### Description |
| 158 | + |
| 159 | +Contient un message avec plus d'informations. |
| 160 | + |
| 161 | +:::demo A coté de l'attribut `title`, vous pouvez ajouter `description` pour décrire l'alerte avec plus de précisions. Les descriptions ne peuvent contenir que du texte, et les retours à la ligne sont automatiques. |
| 162 | + |
| 163 | +```html |
| 164 | +<template> |
| 165 | + <el-alert |
| 166 | + title="avec description" |
| 167 | + type="success" |
| 168 | + description="Ceci est la description."> |
| 169 | + </el-alert> |
| 170 | +</template> |
| 171 | +``` |
| 172 | +::: |
| 173 | + |
| 174 | +### Icône et description |
| 175 | + |
| 176 | +:::demo Pour finir, voici un exemple utilisant à la fois l'icône et la description. |
| 177 | + |
| 178 | +```html |
| 179 | +<template> |
| 180 | + <el-alert |
| 181 | + title="succès" |
| 182 | + type="success" |
| 183 | + description="Plus de texte pour décrire." |
| 184 | + show-icon> |
| 185 | + </el-alert> |
| 186 | + <el-alert |
| 187 | + title="information" |
| 188 | + type="info" |
| 189 | + description="Plus de texte pour décrire." |
| 190 | + show-icon> |
| 191 | + </el-alert> |
| 192 | + <el-alert |
| 193 | + title="avertissement" |
| 194 | + type="warning" |
| 195 | + description="Plus de texte pour décrire." |
| 196 | + show-icon> |
| 197 | + </el-alert> |
| 198 | + <el-alert |
| 199 | + title="erreur" |
| 200 | + type="error" |
| 201 | + description="Plus de texte pour décrire." |
| 202 | + show-icon> |
| 203 | + </el-alert> |
| 204 | +</template> |
| 205 | +``` |
| 206 | +::: |
| 207 | + |
| 208 | +### Attributs |
| 209 | +| Attribut | Description | Type | Valeurs acceptées | Défaut | |
| 210 | +|---------- |-------------- |---------- |-------------------------------- |-------- | |
| 211 | +| title | Titre. | string | — | — | |
| 212 | +| type | Type du composant. | string | success/warning/info/error | info | |
| 213 | +| description | Texte de description. Peut aussi être passé via le slot par défaut | string | — | — | |
| 214 | +| closable | Si peut être fermé ou non. | boolean | — | true | |
| 215 | +| center | Si le texte doit être centré ou non. | boolean | — | false | |
| 216 | +| close-text | Texte personnalisé pour le bouton de fermeture. | string | — | — | |
| 217 | +| show-icon | Si une icône s'affiche ou non. | boolean | — | false | |
| 218 | + |
| 219 | +### Slot |
| 220 | + |
| 221 | +| Nom | Description | |
| 222 | +|------|--------| |
| 223 | +| title | Le contenu du titre. | |
| 224 | + |
| 225 | +### Évènements |
| 226 | +| Nom | Description | Paramètres | |
| 227 | +|---------- |-------- |---------- | |
| 228 | +| close | Se déclenche lorsque l'alerte est fermée. | — | |
0 commit comments