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

46 lines
886 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.
```tsx
2022-05-21 22:14:15 +08:00
import { Alert, Spin, Switch } from 'antd';
import React, { useState } from 'react';
2015-10-31 02:00:03 +08:00
const App: React.FC = () => {
const [loading, setLoading] = useState(false);
2018-06-27 15:55:04 +08:00
const toggle = (checked: boolean) => {
setLoading(checked);
2019-05-07 14:57:32 +08:00
};
2018-06-27 15:55:04 +08:00
return (
<div>
<Spin spinning={loading}>
<Alert
message="Alert message title"
description="Further details about the context of this alert."
type="info"
/>
</Spin>
<div style={{ marginTop: 16 }}>
Loading state
<Switch checked={loading} onChange={toggle} />
</div>
</div>
);
};
2015-10-31 02:00:03 +08:00
export default App;
2019-05-07 14:57:32 +08:00
```