2016-07-21 10:15:00 +08:00
|
|
|
|
---
|
|
|
|
|
category: Components
|
2022-11-09 12:28:04 +08:00
|
|
|
|
group: 反馈
|
2016-07-21 10:15:00 +08:00
|
|
|
|
title: Spin
|
|
|
|
|
subtitle: 加载中
|
2024-03-22 14:22:42 +08:00
|
|
|
|
description: 用于页面和区块的加载中状态。
|
2022-11-30 20:14:41 +08:00
|
|
|
|
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*5mC5TomY4B0AAAAAAAAAAAAADrJ8AQ/original
|
2023-02-09 22:17:31 +08:00
|
|
|
|
coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*i43_ToFrL8YAAAAAAAAAAAAADrJ8AQ/original
|
2022-11-09 12:28:04 +08:00
|
|
|
|
demo:
|
|
|
|
|
cols: 2
|
2016-07-21 10:15:00 +08:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## 何时使用
|
|
|
|
|
|
|
|
|
|
页面局部处于等待异步数据或正在渲染过程时,合适的加载动效会有效缓解用户的焦虑。
|
|
|
|
|
|
2022-11-09 12:28:04 +08:00
|
|
|
|
## 代码演示
|
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
|
<!-- prettier-ignore -->
|
2022-11-09 12:28:04 +08:00
|
|
|
|
<code src="./demo/basic.tsx">基本用法</code>
|
|
|
|
|
<code src="./demo/size.tsx">各种大小</code>
|
|
|
|
|
<code src="./demo/nested.tsx">卡片加载中</code>
|
|
|
|
|
<code src="./demo/tip.tsx">自定义描述文案</code>
|
|
|
|
|
<code src="./demo/delayAndDebounce.tsx">延迟</code>
|
|
|
|
|
<code src="./demo/custom-indicator.tsx">自定义指示符</code>
|
2024-06-03 11:30:27 +08:00
|
|
|
|
<code src="./demo/percent.tsx" version="5.18.0">进度</code>
|
2023-10-19 13:47:48 +08:00
|
|
|
|
<code src="./demo/fullscreen.tsx">全屏</code>
|
2022-11-09 12:28:04 +08:00
|
|
|
|
|
2016-07-21 10:15:00 +08:00
|
|
|
|
## API
|
|
|
|
|
|
2023-08-08 18:27:48 +08:00
|
|
|
|
通用属性参考:[通用属性](/docs/react/common-props)
|
|
|
|
|
|
2023-10-19 13:47:48 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
|
|
|
|
| --- | --- | --- | --- | --- |
|
|
|
|
|
| delay | 延迟显示加载效果的时间(防止闪烁) | number (毫秒) | - |
|
2024-06-03 11:30:27 +08:00
|
|
|
|
| fullscreen | 显示带有 `Spin` 组件的背景 | boolean | false | 5.11.0 |
|
|
|
|
|
| indicator | 加载指示符 | ReactNode | - | |
|
|
|
|
|
| percent | 展示进度,当设置 `percent="auto"` 时会预估一个永远不会停止的进度 | number \| 'auto' | - | 5.18.0 |
|
|
|
|
|
| size | 组件大小,可选值为 `small` `default` `large` | string | `default` | |
|
|
|
|
|
| spinning | 是否为加载中状态 | boolean | true | |
|
2023-10-19 13:47:48 +08:00
|
|
|
|
| tip | 当作为包裹元素时,可以自定义描述文案 | ReactNode | - |
|
|
|
|
|
| wrapperClassName | 包装器的类属性 | string | - |
|
2018-06-06 19:32:30 +08:00
|
|
|
|
|
|
|
|
|
### 静态方法
|
|
|
|
|
|
2019-12-20 15:07:18 +08:00
|
|
|
|
- `Spin.setDefaultIndicator(indicator: ReactNode)`
|
|
|
|
|
|
|
|
|
|
你可以自定义全局默认 Spin 的元素。
|
2023-04-11 10:25:24 +08:00
|
|
|
|
|
2023-08-30 23:02:35 +08:00
|
|
|
|
## 主题变量(Design Token)
|
2023-04-11 10:25:24 +08:00
|
|
|
|
|
|
|
|
|
<ComponentTokenTable component="Spin"></ComponentTokenTable>
|