ant-design/components/spin/demo/nested.md

47 lines
919 B
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 3
title:
zh-CN: 卡片加载中
en-US: Embedded mode
2016-03-31 09:40:55 +08:00
---
2015-10-31 02:00:03 +08:00
## zh-CN
2015-10-31 02:00:03 +08:00
可以直接把内容内嵌到 `Spin` 中,将现有容器变为加载状态。
## en-US
2019-04-19 22:38:41 +08:00
Embedding content into `Spin` will set it into loading state.
2019-05-07 14:57:32 +08:00
```jsx
2015-11-03 22:41:57 +08:00
import { Spin, Switch, Alert } from 'antd';
2015-10-31 02:00:03 +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 => {
2016-05-09 16:11:54 +08:00
this.setState({ loading: value });
2019-05-07 14:57:32 +08:00
};
2018-06-27 15:55:04 +08:00
2017-06-14 13:48:00 +08:00
render() {
return (
<div>
2017-06-14 13:31:21 +08:00
<Spin spinning={this.state.loading}>
<Alert
message="Alert message title"
description="Further details about the context of this alert."
type="info"
/>
</Spin>
<div style={{ marginTop: 16 }}>
2019-05-07 14:57:32 +08:00
Loading state
<Switch checked={this.state.loading} onChange={this.toggle} />
2017-06-14 13:31:21 +08:00
</div>
</div>
);
}
}
2015-10-31 02:00:03 +08:00
ReactDOM.render(<Card />, mountNode);
2019-05-07 14:57:32 +08:00
```