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: 加载中
|
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/inside.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>
|
|
|
|
|
|
2016-07-21 10:15:00 +08:00
|
|
|
|
## API
|
|
|
|
|
|
2023-08-08 18:27:48 +08:00
|
|
|
|
通用属性参考:[通用属性](/docs/react/common-props)
|
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 |
|
|
|
|
|
| ---------------- | -------------------------------------------- | ------------- | --------- |
|
|
|
|
|
| delay | 延迟显示加载效果的时间(防止闪烁) | number (毫秒) | - |
|
|
|
|
|
| indicator | 加载指示符 | ReactNode | - |
|
|
|
|
|
| size | 组件大小,可选值为 `small` `default` `large` | string | `default` |
|
|
|
|
|
| spinning | 是否为加载中状态 | boolean | true |
|
|
|
|
|
| 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>
|