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

54 lines
1.0 KiB
Markdown
Raw Normal View History

2015-06-15 14:43:27 +08:00
# 动态展示
- order: 4
会动的进度条才是好进度条。
---
````jsx
2015-11-03 14:25:36 +08:00
import { Progress, Button, Icon } from 'antd';
const ProgressLine = Progress.Line;
2015-11-03 14:25:36 +08:00
const ButtonGroup = Button.Group;
2015-06-15 14:43:27 +08:00
const MyProgress = React.createClass({
2015-06-15 14:43:27 +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 14:43:27 +08:00
},
render() {
return (
<div>
<ProgressLine percent={this.state.percent} />
<ButtonGroup>
<Button type="ghost" onClick={this.decline}>
<Icon type="minus" />
</Button>
<Button type="ghost" onClick={this.increase}>
<Icon type="plus" />
</Button>
</ButtonGroup>
</div>
);
2015-06-15 14:43:27 +08:00
}
});
ReactDOM.render(<MyProgress />, mountNode);
2015-06-15 14:43:27 +08:00
````