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

53 lines
1.0 KiB
Markdown
Raw Normal View History

2015-06-15 14:43:27 +08:00
# 动态展示
- order: 4
会动的进度条才是好进度条。
---
````jsx
2015-06-15 15:11:02 +08:00
var Progress = antd.Progress.Line;
var Button = antd.Button;
var ButtonGroup = antd.ButtonGroup;
2015-10-02 15:58:37 +08:00
var Icon = antd.Icon;
2015-06-15 14:43:27 +08:00
var MyProgress = React.createClass({
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() {
2015-09-22 20:11:28 +08:00
return <div>
<Progress percent={this.state.percent} />
<ButtonGroup>
<Button type="ghost" onClick={this.decline}>
2015-10-02 15:58:37 +08:00
<Icon type="minus" />
</Button>
<Button type="ghost" onClick={this.increase}>
2015-10-02 15:58:37 +08:00
<Icon type="plus" />
</Button>
</ButtonGroup>
2015-09-22 20:11:28 +08:00
</div>;
2015-06-15 14:43:27 +08:00
}
});
2015-09-22 20:11:28 +08:00
React.render(<MyProgress />, document.getElementById('components-progress-demo-dynamic'));
2015-06-15 14:43:27 +08:00
````