feat: add Badge component (#7602)

This commit is contained in:
neverland
2020-11-22 10:26:59 +08:00
committed by GitHub
parent cda5e0869e
commit 28a04148f1
12 changed files with 467 additions and 0 deletions
+77
View File
@@ -0,0 +1,77 @@
# Badge
### Install
```js
import Vue from 'vue';
import { Badge } from 'vant';
Vue.use(Badge);
```
## Usage
### Basic Usage
```html
<van-badge content="5">
<div class="child" />
</van-badge>
<van-badge dot>
<div class="child" />
</van-badge>
<style>
.child {
width: 36px;
height: 36px;
background: #f2f3f5;
border-radius: 4px;
}
</style>
```
### Max
```html
<van-badge content="20" max="9">
<div class="child" />
</van-badge>
<van-badge content="200" max="99">
<div class="child" />
</van-badge>
```
### Custom Color
```html
<van-badge content="5" color="#1989fa">
<div class="child" />
</van-badge>
<van-badge dot color="#1989fa">
<div class="child" />
</van-badge>
```
### Standaline
```html
<van-badge content="200" max="99" />
```
## API
### Props
| Attribute | Description | Type | Default |
| --- | --- | --- | --- |
| content | Badge content | _number \| string_ | - |
| color | Background color | _string_ | `#ee0a24` |
| dot | Whether to show dot | _boolean_ | `false` |
| max | Max valueshow `{max}+` when exceedonly works when content is number | _number \| string_ | - |
### Slots
| Name | Description |
| ------- | ------------ |
| default | Default slot |