Progress进度条

进度条。

何时使用

展示进度。

代码演示

Progress 进度条 - 图1

进度条

进度条。

  1. import { Progress } from 'choerodon-ui/pro';
  2. ReactDOM.render(
  3. <div>
  4. <Progress value={40} />
  5. <Progress value={50} status="active" />
  6. <Progress value={70} status="exception" />
  7. <Progress value={50} status="success" />
  8. <Progress value={40} showInfo={false} />
  9. </div>,
  10. mountNode
  11. );

Progress 进度条 - 图2

数据源

绑定数据源。

  1. import { DataSet, Progress } from 'choerodon-ui/pro';
  2. class App extends React.Component {
  3. ds = new DataSet({
  4. autoCreate: true,
  5. fields: [
  6. { name: 'percent', type: 'number', defaultValue: 20 },
  7. ],
  8. });
  9. render() {
  10. return <Progress dataSet={this.ds} name="percent" />;
  11. }
  12. }
  13. ReactDOM.render(
  14. <App />,
  15. mountNode
  16. );

Progress 进度条 - 图3

圆形进度条

圆形进度条。

  1. import { Progress } from 'choerodon-ui/pro';
  2. function format() {
  3. return 'Done';
  4. }
  5. ReactDOM.render(
  6. <div>
  7. <Progress value={75} type="circle" size="small" />
  8. <Progress value={100} type="circle" format={format} status="success" />
  9. <Progress value={35} type="circle" status="exception" size="large" />
  10. </div>,
  11. mountNode
  12. );

Progress 进度条 - 图4

加载

加载。

  1. import { Progress } from 'choerodon-ui/pro';
  2. ReactDOM.render(
  3. <div>
  4. <Progress type="loading" size="small" />
  5. <Progress type="loading" status="success" />
  6. <Progress type="loading" size="large" status="exception" />
  7. </div>,
  8. mountNode
  9. );

Progress 进度条 - 图5

受控

受控。

  1. import { Progress } from 'choerodon-ui/pro';
  2. class App extends React.Component {
  3. constructor(props) {
  4. super(props);
  5. this.state = {
  6. completed: 0,
  7. status: 'active',
  8. };
  9. }
  10. componentDidMount() {
  11. this.timer = setTimeout(() => this.progress(5), 1000);
  12. }
  13. componentWillUnmount() {
  14. clearTimeout(this.timer);
  15. }
  16. progress(completed) {
  17. if (completed > 100) {
  18. this.setState({
  19. completed: 100,
  20. status: 'success',
  21. });
  22. } else {
  23. this.setState({
  24. completed,
  25. });
  26. const diff = Math.round(Math.random() * 10);
  27. this.timer = setTimeout(() => this.progress(completed + diff), 1000);
  28. }
  29. }
  30. render() {
  31. return (
  32. <div>
  33. <Progress value={this.state.completed} status={this.state.status} />
  34. <Progress type="circle" value={this.state.completed} status={this.state.status} />
  35. <Progress type="dashboard" value={this.state.completed} status={this.state.status} />
  36. </div>
  37. );
  38. }
  39. }
  40. ReactDOM.render(
  41. <App />,
  42. mountNode
  43. );

Progress 进度条 - 图6

自定义文字格式

自定义文字格式。

  1. import { Progress } from 'choerodon-ui/pro';
  2. function format() {
  3. return 'Done';
  4. }
  5. ReactDOM.render(
  6. <Progress value={100} format={format} status="success" />,
  7. mountNode
  8. );

Progress 进度条 - 图7

仪表盘进度条

仪表盘

  1. import { Progress } from 'choerodon-ui/pro';
  2. ReactDOM.render(
  3. <div>
  4. <Progress value={75} type="dashboard" />
  5. <Progress value={100} type="dashboard" status="success" />
  6. <Progress value={25} type="dashboard" status="exception" />
  7. </div>,
  8. mountNode
  9. );

API

Progress 的属性说明如下:

参数说明类型默认值
value当前百分比值,同percent,受控。number-
dataSet数据源DataSet-
name字段名string-

更多属性请参考 Progress