ant-design-vue/components/progress/demo/dynamic.vue

47 lines
941 B
Vue

<docs>
---
order: 4
title:
zh-CN: 动态展示
en-US: Dynamic
---
## zh-CN
会动的进度条才是好进度条
## en-US
A dynamic progress bar is better.
</docs>
<template>
<div>
<a-progress :percent="defaultPercent" />
<a-button-group>
<a-button @click="decline">
<template #icon><minus-outlined /></template>
</a-button>
<a-button @click="increase">
<template #icon><plus-outlined /></template>
</a-button>
</a-button-group>
</div>
</template>
<script lang="ts" setup>
import { MinusOutlined, PlusOutlined } from '@ant-design/icons-vue';
import { ref } from 'vue';
const defaultPercent = ref<number>(0);
const increase = () => {
const percent = defaultPercent.value + 10;
defaultPercent.value = percent > 100 ? 100 : percent;
};
const decline = () => {
const percent = defaultPercent.value - 10;
defaultPercent.value = percent < 0 ? 0 : percent;
};
</script>