Progress进度条
进度条。
何时使用
展示进度。
代码演示
进度条。
import { Progress } from 'choerodon-ui/pro';
ReactDOM.render(
<div>
<Progress value={40} />
<Progress value={50} status="active" />
<Progress value={70} status="exception" />
<Progress value={50} status="success" />
<Progress value={40} showInfo={false} />
</div>,
mountNode
);
绑定数据源。
import { DataSet, Progress } from 'choerodon-ui/pro';
class App extends React.Component {
ds = new DataSet({
autoCreate: true,
fields: [
{ name: 'percent', type: 'number', defaultValue: 20 },
],
});
render() {
return <Progress dataSet={this.ds} name="percent" />;
}
}
ReactDOM.render(
<App />,
mountNode
);
圆形进度条。
import { Progress } from 'choerodon-ui/pro';
function format() {
return 'Done';
}
ReactDOM.render(
<div>
<Progress value={75} type="circle" size="small" />
<Progress value={100} type="circle" format={format} status="success" />
<Progress value={35} type="circle" status="exception" size="large" />
</div>,
mountNode
);
加载。
import { Progress } from 'choerodon-ui/pro';
ReactDOM.render(
<div>
<Progress type="loading" size="small" />
<Progress type="loading" status="success" />
<Progress type="loading" size="large" status="exception" />
</div>,
mountNode
);
受控。
import { Progress } from 'choerodon-ui/pro';
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
completed: 0,
status: 'active',
};
}
componentDidMount() {
this.timer = setTimeout(() => this.progress(5), 1000);
}
componentWillUnmount() {
clearTimeout(this.timer);
}
progress(completed) {
if (completed > 100) {
this.setState({
completed: 100,
status: 'success',
});
} else {
this.setState({
completed,
});
const diff = Math.round(Math.random() * 10);
this.timer = setTimeout(() => this.progress(completed + diff), 1000);
}
}
render() {
return (
<div>
<Progress value={this.state.completed} status={this.state.status} />
<Progress type="circle" value={this.state.completed} status={this.state.status} />
<Progress type="dashboard" value={this.state.completed} status={this.state.status} />
</div>
);
}
}
ReactDOM.render(
<App />,
mountNode
);
自定义文字格式。
import { Progress } from 'choerodon-ui/pro';
function format() {
return 'Done';
}
ReactDOM.render(
<Progress value={100} format={format} status="success" />,
mountNode
);
仪表盘
import { Progress } from 'choerodon-ui/pro';
ReactDOM.render(
<div>
<Progress value={75} type="dashboard" />
<Progress value={100} type="dashboard" status="success" />
<Progress value={25} type="dashboard" status="exception" />
</div>,
mountNode
);
API
Progress 的属性说明如下:
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
value | 当前百分比值,同percent,受控。 | number | - |
dataSet | 数据源 | DataSet | - |
name | 字段名 | string | - |
更多属性请参考 Progress。