2015-06-15 16:49:37 +08:00
|
|
|
# 进度圈动态展示
|
2015-06-15 16:31:51 +08:00
|
|
|
|
|
|
|
- order: 4
|
|
|
|
|
|
|
|
会动的进度条才是好进度条。
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
````jsx
|
2015-11-03 14:25:36 +08:00
|
|
|
import { Progress, Button, Icon } from 'antd';
|
2015-10-28 20:55:49 +08:00
|
|
|
const ProgressCircle = Progress.Circle;
|
2015-11-03 14:25:36 +08:00
|
|
|
const ButtonGroup = Button.Group;
|
2015-06-15 16:31:51 +08:00
|
|
|
|
2015-10-28 20:55:49 +08:00
|
|
|
const MyProgress = React.createClass({
|
2015-06-15 16:31:51 +08:00
|
|
|
getInitialState() {
|
|
|
|
return {
|
|
|
|
percent: 0
|
|
|
|
};
|
|
|
|
},
|
2015-09-22 20:11:28 +08:00
|
|
|
increase() {
|
|
|
|
let percent = this.state.percent + 10;
|
|
|
|
if (percent > 100) {
|
|
|
|
percent = 100;
|
|
|
|
}
|
|
|
|
this.setState({ percent });
|
|
|
|
},
|
|
|
|
decline() {
|
|
|
|
let percent = this.state.percent - 10;
|
|
|
|
if (percent < 0) {
|
|
|
|
percent = 0;
|
|
|
|
}
|
|
|
|
this.setState({ percent });
|
2015-06-15 16:31:51 +08:00
|
|
|
},
|
|
|
|
render() {
|
2015-09-22 20:11:28 +08:00
|
|
|
return <div>
|
|
|
|
<ProgressCircle percent={this.state.percent} />
|
2015-10-08 15:13:04 +08:00
|
|
|
<ButtonGroup>
|
|
|
|
<Button type="ghost" onClick={this.decline}>
|
2015-10-02 15:58:37 +08:00
|
|
|
<Icon type="minus" />
|
2015-10-08 15:13:04 +08:00
|
|
|
</Button>
|
|
|
|
<Button type="ghost" onClick={this.increase}>
|
2015-10-02 15:58:37 +08:00
|
|
|
<Icon type="plus" />
|
2015-10-08 15:13:04 +08:00
|
|
|
</Button>
|
|
|
|
</ButtonGroup>
|
2015-09-22 20:11:28 +08:00
|
|
|
</div>;
|
2015-06-15 16:31:51 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-12-29 12:08:58 +08:00
|
|
|
ReactDOM.render(<MyProgress />, mountNode);
|
2015-06-15 16:31:51 +08:00
|
|
|
````
|
|
|
|
|