-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
296 additions
and
8,784 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
sidebar_position: 8 | ||
--- | ||
|
||
# 8.3. Button | ||
<intro type="must" /> | ||
|
||
对于包含`接口请求状态`的按钮,必须把 `loading` 状态传递给 `Button` 组件,以便于在请求过程中禁用按钮。 | ||
|
||
设置 C7N 组件库的按钮的 `loading` 方式常见有以下两种: | ||
|
||
1. 通过 `Button` 组件的 `loading` 属性设置 | ||
2. 通过 `Button` 组件的 `onClick` 属性设置,且 `onClick` 返回一个 `Promise` 对象。若 `Promise` 对象处于 `pending` 状态,则按钮就处于 `loading` 状态。 | ||
|
||
例: | ||
``` tsx | ||
function App() { | ||
const handleClick = React.useCallback(() => { | ||
return new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, 2000); | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<Button onClick={handleClick}> | ||
Click Me | ||
</Button> | ||
); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.