2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 4
|
2016-07-26 15:42:04 +08:00
|
|
|
title:
|
|
|
|
zh-CN: 进度圈动态展示
|
|
|
|
en-US: Dynamic circular progress bar
|
2016-03-31 09:40:55 +08:00
|
|
|
---
|
2015-06-15 16:31:51 +08:00
|
|
|
|
2016-07-26 15:42:04 +08:00
|
|
|
## zh-CN
|
|
|
|
|
2015-06-15 16:31:51 +08:00
|
|
|
会动的进度条才是好进度条。
|
|
|
|
|
2016-07-26 15:42:04 +08:00
|
|
|
## en-US
|
|
|
|
|
|
|
|
A dynamic progress bar is better.
|
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
```jsx
|
2016-04-06 15:43:50 +08:00
|
|
|
import { Progress, Button } from 'antd';
|
2019-11-28 12:34:33 +08:00
|
|
|
import { MinusOutlined, PlusOutlined } from '@ant-design/icons';
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2017-02-20 22:07:45 +08:00
|
|
|
class App extends React.Component {
|
|
|
|
state = {
|
|
|
|
percent: 0,
|
2019-05-07 14:57:32 +08:00
|
|
|
};
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2017-02-20 22:07:45 +08:00
|
|
|
increase = () => {
|
2015-09-22 20:11:28 +08:00
|
|
|
let percent = this.state.percent + 10;
|
|
|
|
if (percent > 100) {
|
|
|
|
percent = 100;
|
|
|
|
}
|
|
|
|
this.setState({ percent });
|
2019-05-07 14:57:32 +08:00
|
|
|
};
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2017-02-20 22:07:45 +08:00
|
|
|
decline = () => {
|
2015-09-22 20:11:28 +08:00
|
|
|
let percent = this.state.percent - 10;
|
|
|
|
if (percent < 0) {
|
|
|
|
percent = 0;
|
|
|
|
}
|
|
|
|
this.setState({ percent });
|
2019-05-07 14:57:32 +08:00
|
|
|
};
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2015-06-15 16:31:51 +08:00
|
|
|
render() {
|
2016-01-07 16:29:12 +08:00
|
|
|
return (
|
2020-05-25 16:27:02 +08:00
|
|
|
<>
|
2016-04-05 16:51:26 +08:00
|
|
|
<Progress type="circle" percent={this.state.percent} />
|
2020-05-25 16:27:02 +08:00
|
|
|
<Button.Group>
|
2019-11-28 12:34:33 +08:00
|
|
|
<Button onClick={this.decline} icon={<MinusOutlined />} />
|
|
|
|
<Button onClick={this.increase} icon={<PlusOutlined />} />
|
2020-05-25 16:27:02 +08:00
|
|
|
</Button.Group>
|
|
|
|
</>
|
2016-01-07 16:29:12 +08:00
|
|
|
);
|
2017-02-20 22:07:45 +08:00
|
|
|
}
|
|
|
|
}
|
2015-06-15 16:31:51 +08:00
|
|
|
|
2022-04-15 16:20:56 +08:00
|
|
|
export default App;
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|