Progress 进度条

定义/Definition

进度视图展示了任务或进程的进度。

规则 / Rule

  • 是一条轨迹,随着进程的进行从左向右进行填充;

  • 不支持用户交互行为

代码演示

基本

基本功能展示

  1. import { Progress, WhiteSpace, Button, Flex, WingBlank } from 'antd-mobile';
  2. const MyProgress = React.createClass({
  3. getInitialState() {
  4. return {
  5. percent: 0,
  6. };
  7. },
  8. increase() {
  9. let percent = this.state.percent + 10;
  10. if (percent > 100) {
  11. percent = 100;
  12. }
  13. this.setState({ percent, status });
  14. },
  15. decline() {
  16. let percent = this.state.percent - 10;
  17. if (percent < 0) {
  18. percent = 0;
  19. }
  20. this.setState({ percent, status });
  21. },
  22. render() {
  23. return (
  24. <div className="progress-container">
  25. {this.state.percent === 100 ? null :
  26. <Progress percent={this.state.percent} position="fixed" />
  27. }
  28. <Progress percent={this.state.percent} position="normal" />
  29. <WhiteSpace size={20} />
  30. <WingBlank size={20}>
  31. <Flex>
  32. <Flex.Item>
  33. <Button onClick={this.increase}> + </Button>
  34. </Flex.Item>
  35. <Flex.Item>
  36. <Button onClick={this.decline}> - </Button>
  37. </Flex.Item>
  38. </Flex>
  39. </WingBlank>
  40. <WhiteSpace size={20} />
  41. </div>
  42. );
  43. },
  44. });
  45. ReactDOM.render(<MyProgress />, mountNode);

Progress进度条 - 图1

API

属性说明类型默认值
percent进度百分比number0
position进度条的位置,fixed将浮出固定在最顶层,可选:fixednormalstringfixed