2020-08-13 15:18:26 +08:00
|
|
|
## Badge
|
|
|
|
|
|
|
|
Marcas en forma de número o estado para botones e iconos.
|
|
|
|
|
|
|
|
### Uso básico
|
|
|
|
|
|
|
|
Muestra la cantidad de mensajes nuevos.
|
|
|
|
|
|
|
|
:::demo La cantidad está definida por `value` que acepta `Number` o `String`.
|
|
|
|
|
|
|
|
```html
|
|
|
|
<el-badge :value="12" class="item">
|
|
|
|
<el-button size="small">comments</el-button>
|
|
|
|
</el-badge>
|
|
|
|
<el-badge :value="3" class="item">
|
|
|
|
<el-button size="small">replies</el-button>
|
|
|
|
</el-badge>
|
|
|
|
<el-badge :value="1" class="item" type="primary">
|
|
|
|
<el-button size="small">comments</el-button>
|
|
|
|
</el-badge>
|
|
|
|
<el-badge :value="2" class="item" type="warning">
|
|
|
|
<el-button size="small">replies</el-button>
|
|
|
|
</el-badge>
|
|
|
|
|
|
|
|
<el-dropdown trigger="click">
|
|
|
|
<span class="el-dropdown-link">
|
|
|
|
Click Me<i class="el-icon-caret-bottom el-icon--right"></i>
|
|
|
|
</span>
|
2020-11-29 18:50:46 +08:00
|
|
|
<template #dropdown>
|
|
|
|
<el-dropdown-menu>
|
|
|
|
<el-dropdown-item class="clearfix">
|
|
|
|
comments
|
|
|
|
<el-badge class="mark" :value="12" />
|
|
|
|
</el-dropdown-item>
|
|
|
|
<el-dropdown-item class="clearfix">
|
|
|
|
replies
|
|
|
|
<el-badge class="mark" :value="3" />
|
|
|
|
</el-dropdown-item>
|
|
|
|
</el-dropdown-menu>
|
|
|
|
</template>
|
2020-08-13 15:18:26 +08:00
|
|
|
</el-dropdown>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.item {
|
|
|
|
margin-top: 10px;
|
|
|
|
margin-right: 40px;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
```
|
|
|
|
:::
|
|
|
|
|
|
|
|
### Valor máximo
|
|
|
|
|
|
|
|
Se puede personalizar el valor máximo.
|
|
|
|
|
|
|
|
:::demo El valor máximo se define como `max` el cual es un `Number`. Nota: solo funciona si `value` es también un `Number`.
|
|
|
|
|
|
|
|
```html
|
|
|
|
<el-badge :value="200" :max="99" class="item">
|
|
|
|
<el-button size="small">comments</el-button>
|
|
|
|
</el-badge>
|
|
|
|
<el-badge :value="100" :max="10" class="item">
|
|
|
|
<el-button size="small">replies</el-button>
|
|
|
|
</el-badge>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.item {
|
|
|
|
margin-top: 10px;
|
|
|
|
margin-right: 40px;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
```
|
|
|
|
:::
|
|
|
|
|
|
|
|
### Personalizaciones
|
|
|
|
|
|
|
|
Mostrar texto en vez de números.
|
|
|
|
|
|
|
|
:::demo Cuando `value` es un `String`, puede mostrar texto personalizado.
|
|
|
|
|
|
|
|
```html
|
|
|
|
<el-badge value="new" class="item">
|
|
|
|
<el-button size="small">comments</el-button>
|
|
|
|
</el-badge>
|
|
|
|
<el-badge value="hot" class="item">
|
|
|
|
<el-button size="small">replies</el-button>
|
|
|
|
</el-badge>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.item {
|
|
|
|
margin-top: 10px;
|
|
|
|
margin-right: 40px;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
```
|
|
|
|
:::
|
|
|
|
|
|
|
|
### Pequeño punto rojo
|
|
|
|
|
|
|
|
Puede utilizar un punto rojo para marcar contenido que debe ser notado.
|
|
|
|
|
|
|
|
:::demo Use el atributo `is-dot`. Es un `Boolean`.
|
|
|
|
|
|
|
|
```html
|
|
|
|
<el-badge is-dot class="item">query</el-badge>
|
|
|
|
<el-badge is-dot class="item">
|
|
|
|
<el-button class="share-button" icon="el-icon-share" type="primary"></el-button>
|
|
|
|
</el-badge>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.item {
|
|
|
|
margin-top: 10px;
|
|
|
|
margin-right: 40px;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
```
|
|
|
|
:::
|
|
|
|
|
|
|
|
### Atributos
|
|
|
|
| Atributo | Descripción | Tipo | Valores aceptados | Por defecto |
|
|
|
|
| -------- | ---------------------------------------- | -------------- | ----------------- | ----------- |
|
|
|
|
| value | valor a mostrar | string, number | — | — |
|
|
|
|
| max | valor máximo, Muestra '{max}+' cuando se excede. Solo funciona si `value` es un `Number` | number | — | — |
|
|
|
|
| is-dot | si se debe mostrar un pequeño punto | boolean | — | false |
|
|
|
|
| hidden | oculta el badge | boolean | — | false |
|
|
|
|
| type | tipo de botón | string | primary / success / warning / danger / info | — |
|
|
|
|
|