2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 4
|
2016-07-26 15:42:04 +08:00
|
|
|
title:
|
|
|
|
zh-CN: 动态展示
|
|
|
|
en-US: Dynamic
|
2016-03-31 09:40:55 +08:00
|
|
|
---
|
2015-06-15 14:43:27 +08:00
|
|
|
|
2016-07-26 15:42:04 +08:00
|
|
|
## zh-CN
|
|
|
|
|
2015-06-15 14:43:27 +08:00
|
|
|
会动的进度条才是好进度条。
|
|
|
|
|
2016-07-26 15:42:04 +08:00
|
|
|
## en-US
|
|
|
|
|
|
|
|
A dynamic progress bar is better.
|
|
|
|
|
2017-02-13 10:55:53 +08:00
|
|
|
````jsx
|
2016-04-06 15:43:50 +08:00
|
|
|
import { Progress, Button } from 'antd';
|
2015-11-03 14:25:36 +08:00
|
|
|
const ButtonGroup = Button.Group;
|
2015-06-15 14:43:27 +08:00
|
|
|
|
2015-10-28 20:55:49 +08:00
|
|
|
const MyProgress = React.createClass({
|
2015-06-15 14:43:27 +08:00
|
|
|
getInitialState() {
|
|
|
|
return {
|
2016-05-11 09:32:33 +08:00
|
|
|
percent: 0,
|
2015-06-15 14:43:27 +08:00
|
|
|
};
|
|
|
|
},
|
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() {
|
2016-01-07 16:29:12 +08:00
|
|
|
return (
|
|
|
|
<div>
|
2016-04-05 16:51:26 +08:00
|
|
|
<Progress percent={this.state.percent} />
|
2016-01-07 16:29:12 +08:00
|
|
|
<ButtonGroup>
|
2017-02-04 22:35:33 +08:00
|
|
|
<Button onClick={this.decline} icon="minus" />
|
|
|
|
<Button onClick={this.increase} icon="plus" />
|
2016-01-07 16:29:12 +08:00
|
|
|
</ButtonGroup>
|
|
|
|
</div>
|
|
|
|
);
|
2016-05-11 09:32:33 +08:00
|
|
|
},
|
2015-06-15 14:43:27 +08:00
|
|
|
});
|
|
|
|
|
2015-12-29 12:08:58 +08:00
|
|
|
ReactDOM.render(<MyProgress />, mountNode);
|
2015-06-15 14:43:27 +08:00
|
|
|
````
|