2020-01-27 18:03:10 +08:00
|
|
|
# Controlled Display
|
2019-10-09 17:38:08 +08:00
|
|
|
```html
|
2020-03-12 21:32:47 +08:00
|
|
|
<div class="badge-demo">
|
2019-10-09 17:38:08 +08:00
|
|
|
<n-badge :value="value" :max="15" :show="show">
|
2020-03-12 21:32:47 +08:00
|
|
|
<n-avatar />
|
2019-10-09 17:38:08 +08:00
|
|
|
</n-badge>
|
|
|
|
<n-badge :value="value" dot :show="show">
|
2020-03-12 21:32:47 +08:00
|
|
|
<n-avatar />
|
2019-10-09 17:38:08 +08:00
|
|
|
</n-badge>
|
|
|
|
<n-button-group>
|
2019-10-24 18:04:31 +08:00
|
|
|
<n-button @click="value = Math.min(16, value + 1)">
|
|
|
|
<template v-slot:icon>
|
|
|
|
<n-icon><md-add /></n-icon>
|
|
|
|
</template>
|
|
|
|
</n-button>
|
|
|
|
<n-button @click="value = Math.max(0, value - 1)" >
|
|
|
|
<template v-slot:icon>
|
|
|
|
<n-icon><md-remove /></n-icon>
|
|
|
|
</template>
|
|
|
|
</n-button>
|
2019-10-09 17:38:08 +08:00
|
|
|
</n-button-group>
|
|
|
|
<n-switch v-model="show"/>
|
|
|
|
</div>
|
|
|
|
```
|
|
|
|
```js
|
2019-10-25 12:48:10 +08:00
|
|
|
import mdAdd from 'naive-ui/lib/icons/md-add'
|
|
|
|
import mdRemove from 'naive-ui/lib/icons/md-remove'
|
2019-10-24 18:04:31 +08:00
|
|
|
|
2019-10-09 17:38:08 +08:00
|
|
|
export default {
|
2019-10-24 18:04:31 +08:00
|
|
|
components: {
|
|
|
|
mdAdd,
|
|
|
|
mdRemove
|
|
|
|
},
|
2019-10-09 17:38:08 +08:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
value: 5,
|
|
|
|
show: true
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
```
|
|
|
|
```css
|
|
|
|
.n-badge {
|
|
|
|
margin: 0 32px 0px 0;
|
|
|
|
}
|
2020-03-12 21:32:47 +08:00
|
|
|
.badge-demo {
|
2019-10-09 17:38:08 +08:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
```
|