naive-ui/demo/documentation/components/badge/zhCN/overflow.demo.md
2020-11-07 00:07:02 +08:00

931 B

溢出

设定 max 来处理溢出情况。

<n-space :size="24" align="center">
  <n-badge :value="value" show-zero>
    <n-avatar />
  </n-badge>
  <n-badge :value="value" :max="99">
    <n-avatar />
  </n-badge>
  <n-badge :value="value" show-zero :max="100">
    <n-avatar />
  </n-badge>
  <n-badge :value="value" show-zero :max="10">
    <n-avatar />
  </n-badge>
  <n-button-group>
    <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>
  </n-button-group>
</n-space>
import {
  MdAdd,
  MdRemove
} from '@vicons/ionicons-v4'

export default {
  components: {
    MdAdd,
    MdRemove
  },
  data () {
    return {
      value: 101
    }
  }
}