mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-14 09:20:51 +08:00
84321952e0
* style(slider): slider button style change slider button add box-sizing: border-box and change the default size to make sure the style is the same of before. * style(slider): remove outline * fix(docs): replace error v-slot/slot to correct Replace all `v-slot` to `#default`, `v-slot:xxx` to `#xxx`, `slot="xxx"` to `#xxx`. fix #704 * docs: v-slot can not bind on div * fix: fix v-slot
128 lines
3.3 KiB
Markdown
128 lines
3.3 KiB
Markdown
## 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>
|
|
<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>
|
|
</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 | — |
|
|
|