2017-11-06 19:22:02 +08:00
|
|
|
## Badge
|
|
|
|
|
2017-11-08 14:22:06 +08:00
|
|
|
Marcas en forma de número o estado para botones e iconos.
|
2017-11-06 19:22:02 +08:00
|
|
|
|
2017-11-08 14:22:06 +08:00
|
|
|
### Uso básico
|
2017-11-06 19:22:02 +08:00
|
|
|
|
2017-11-08 14:22:06 +08:00
|
|
|
Muestra la cantidad de mensajes nuevos.
|
2017-11-06 19:22:02 +08:00
|
|
|
|
2017-11-08 14:22:06 +08:00
|
|
|
:::demo La cantidad está definida por `value` que acepta `Number` o `String`.
|
2017-11-06 19:22:02 +08:00
|
|
|
|
|
|
|
```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>
|
2018-10-09 12:14:45 +08:00
|
|
|
<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>
|
2017-11-06 19:22:02 +08:00
|
|
|
|
|
|
|
<el-dropdown trigger="click">
|
|
|
|
<span class="el-dropdown-link">
|
|
|
|
Click Me<i class="el-icon-caret-bottom el-icon--right"></i>
|
|
|
|
</span>
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
|
<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>
|
|
|
|
</el-dropdown>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.item {
|
|
|
|
margin-top: 10px;
|
|
|
|
margin-right: 40px;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
```
|
|
|
|
:::
|
|
|
|
|
2017-11-08 14:22:06 +08:00
|
|
|
### Valor máximo
|
2017-11-06 19:22:02 +08:00
|
|
|
|
2017-12-03 18:03:06 +08:00
|
|
|
Se puede personalizar el valor máximo.
|
2017-11-06 19:22:02 +08:00
|
|
|
|
2017-12-12 12:45:09 +08:00
|
|
|
:::demo El valor máximo se define como `max` el cual es un `Number`. Nota: solo funciona si `value` es también un `Number`.
|
2017-11-06 19:22:02 +08:00
|
|
|
|
|
|
|
```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>
|
|
|
|
```
|
|
|
|
:::
|
|
|
|
|
2017-12-03 18:03:06 +08:00
|
|
|
### Personalizaciones
|
2017-11-06 19:22:02 +08:00
|
|
|
|
2017-11-08 14:22:06 +08:00
|
|
|
Mostrar texto en vez de números.
|
2017-11-06 19:22:02 +08:00
|
|
|
|
2017-12-03 18:03:06 +08:00
|
|
|
:::demo Cuando `value` es un `String`, puede mostrar texto personalizado.
|
2017-11-06 19:22:02 +08:00
|
|
|
|
|
|
|
```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>
|
|
|
|
```
|
|
|
|
:::
|
|
|
|
|
2017-11-08 14:22:06 +08:00
|
|
|
### Pequeño punto rojo
|
2017-11-06 19:22:02 +08:00
|
|
|
|
2017-11-08 14:22:06 +08:00
|
|
|
Puede utilizar un punto rojo para marcar contenido que debe ser notado.
|
2017-11-06 19:22:02 +08:00
|
|
|
|
2017-11-08 14:22:06 +08:00
|
|
|
:::demo Use el atributo `is-dot`. Es un `Boolean`.
|
2017-11-06 19:22:02 +08:00
|
|
|
|
|
|
|
```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>
|
|
|
|
```
|
|
|
|
:::
|
|
|
|
|
2017-11-08 14:22:06 +08:00
|
|
|
### Atributos
|
2017-12-03 18:03:06 +08:00
|
|
|
| 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 |
|
2019-04-01 13:43:11 +08:00
|
|
|
| hidden | oculta el badge | boolean | — | false |
|
2018-10-09 12:14:45 +08:00
|
|
|
| type | tipo de botón | string | primary / success / warning / danger / info | — |
|