ant-design/components/progress/demo/circle-dynamic.md
2022-05-23 14:37:16 +08:00

53 lines
1002 B
Markdown

---
order: 4
title:
zh-CN: 进度圈动态展示
en-US: Dynamic circular progress bar
---
## zh-CN
会动的进度条才是好进度条。
## en-US
A dynamic progress bar is better.
```tsx
import { MinusOutlined, PlusOutlined } from '@ant-design/icons';
import { Button, Progress } from 'antd';
import React, { useState } from 'react';
const App: React.FC = () => {
const [percent, setPercent] = useState(0);
const increase = () => {
let newPercent = percent + 10;
if (newPercent > 100) {
newPercent = 100;
}
setPercent(newPercent);
};
const decline = () => {
let newPercent = percent - 10;
if (newPercent < 0) {
newPercent = 0;
}
setPercent(newPercent);
};
return (
<>
<Progress type="circle" percent={percent} />
<Button.Group>
<Button onClick={decline} icon={<MinusOutlined />} />
<Button onClick={increase} icon={<PlusOutlined />} />
</Button.Group>
</>
);
};
export default App;
```