2017-01-01 01:13:34 +08:00
|
|
|
|
---
|
|
|
|
|
order: 5
|
|
|
|
|
title:
|
|
|
|
|
zh-CN: 延迟
|
|
|
|
|
en-US: delay
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
|
|
延迟显示 loading 效果。当 spinning 状态在 `delay` 时间内结束,则不显示 loading 状态。
|
|
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
|
|
Specifies a delay for loading state. If `spinning` ends during delay, loading status won't appear.
|
|
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
|
```jsx
|
2017-01-01 01:13:34 +08:00
|
|
|
|
import { Spin, Alert, Switch } from 'antd';
|
|
|
|
|
|
2017-02-20 22:16:57 +08:00
|
|
|
|
class Card extends React.Component {
|
2019-05-07 14:57:32 +08:00
|
|
|
|
state = { loading: false };
|
2018-06-27 15:55:04 +08:00
|
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
|
toggle = value => {
|
2017-01-01 01:13:34 +08:00
|
|
|
|
this.setState({ loading: value });
|
2019-05-07 14:57:32 +08:00
|
|
|
|
};
|
2018-06-27 15:55:04 +08:00
|
|
|
|
|
2017-01-01 01:13:34 +08:00
|
|
|
|
render() {
|
|
|
|
|
const container = (
|
2017-01-07 22:07:09 +08:00
|
|
|
|
<Alert
|
|
|
|
|
message="Alert message title"
|
2017-01-01 01:13:34 +08:00
|
|
|
|
description="Further details about the context of this alert."
|
|
|
|
|
type="info"
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
2019-05-07 14:57:32 +08:00
|
|
|
|
<Spin spinning={this.state.loading} delay={500}>
|
|
|
|
|
{container}
|
|
|
|
|
</Spin>
|
2017-11-06 21:28:51 +08:00
|
|
|
|
<div style={{ marginTop: 16 }}>
|
2019-05-07 14:57:32 +08:00
|
|
|
|
Loading state:
|
|
|
|
|
<Switch checked={this.state.loading} onChange={this.toggle} />
|
2017-11-06 21:28:51 +08:00
|
|
|
|
</div>
|
2017-01-01 01:13:34 +08:00
|
|
|
|
</div>
|
|
|
|
|
);
|
2017-02-20 22:16:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-01-01 01:13:34 +08:00
|
|
|
|
|
2022-04-03 23:27:45 +08:00
|
|
|
|
export default () => <Card />;
|
2019-05-07 14:57:32 +08:00
|
|
|
|
```
|