2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 3
|
2016-07-21 10:07:30 +08:00
|
|
|
title:
|
2016-11-09 14:45:10 +08:00
|
|
|
zh-CN: 步骤切换
|
|
|
|
en-US: Switch Step
|
2016-03-31 09:40:55 +08:00
|
|
|
---
|
2015-06-25 16:01:04 +08:00
|
|
|
|
2016-07-21 10:07:30 +08:00
|
|
|
## zh-CN
|
|
|
|
|
2016-11-09 14:45:10 +08:00
|
|
|
通常配合内容及按钮使用,表示一个流程的处理进度。
|
2015-06-25 20:01:20 +08:00
|
|
|
|
2016-07-21 10:07:30 +08:00
|
|
|
## en-US
|
|
|
|
|
2016-11-09 14:45:10 +08:00
|
|
|
Cooperate with the content and buttons, to represent the progress of a process.
|
2016-07-21 10:07:30 +08:00
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
```jsx
|
2016-11-09 14:45:10 +08:00
|
|
|
import { Steps, Button, message } from 'antd';
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2019-05-27 21:32:45 +08:00
|
|
|
const { Step } = Steps;
|
2016-11-09 14:45:10 +08:00
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
const steps = [
|
|
|
|
{
|
|
|
|
title: 'First',
|
|
|
|
content: 'First-content',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Second',
|
|
|
|
content: 'Second-content',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Last',
|
|
|
|
content: 'Last-content',
|
|
|
|
},
|
|
|
|
];
|
2016-11-09 14:45:10 +08:00
|
|
|
|
2020-11-05 13:26:20 +08:00
|
|
|
const App = () => {
|
|
|
|
const [current, setCurrent] = React.useState(0);
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2020-11-05 13:26:20 +08:00
|
|
|
const next = () => {
|
|
|
|
setCurrent(current + 1);
|
|
|
|
};
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2020-11-05 13:26:20 +08:00
|
|
|
const prev = () => {
|
|
|
|
setCurrent(current - 1);
|
|
|
|
};
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2020-11-05 13:26:20 +08:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Steps current={current}>
|
|
|
|
{steps.map(item => (
|
|
|
|
<Step key={item.title} title={item.title} />
|
|
|
|
))}
|
|
|
|
</Steps>
|
|
|
|
<div className="steps-content">{steps[current].content}</div>
|
|
|
|
<div className="steps-action">
|
|
|
|
{current < steps.length - 1 && (
|
|
|
|
<Button type="primary" onClick={() => next()}>
|
|
|
|
Next
|
|
|
|
</Button>
|
|
|
|
)}
|
|
|
|
{current === steps.length - 1 && (
|
|
|
|
<Button type="primary" onClick={() => message.success('Processing complete!')}>
|
|
|
|
Done
|
|
|
|
</Button>
|
|
|
|
)}
|
|
|
|
{current > 0 && (
|
|
|
|
<Button style={{ margin: '0 8px' }} onClick={() => prev()}>
|
|
|
|
Previous
|
|
|
|
</Button>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
2015-06-25 18:12:42 +08:00
|
|
|
|
2022-04-03 23:27:45 +08:00
|
|
|
export default () => <App />;
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|
2016-11-09 14:45:10 +08:00
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
```css
|
2016-11-09 14:45:10 +08:00
|
|
|
.steps-content {
|
2021-01-30 19:39:02 +08:00
|
|
|
min-height: 200px;
|
2016-11-09 14:45:10 +08:00
|
|
|
margin-top: 16px;
|
2021-01-30 19:39:02 +08:00
|
|
|
padding-top: 80px;
|
|
|
|
text-align: center;
|
|
|
|
background-color: #fafafa;
|
2016-11-09 14:45:10 +08:00
|
|
|
border: 1px dashed #e9e9e9;
|
2019-12-23 20:07:56 +08:00
|
|
|
border-radius: 2px;
|
2016-11-09 14:45:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.steps-action {
|
2016-12-04 15:50:54 +08:00
|
|
|
margin-top: 24px;
|
2016-11-09 14:45:10 +08:00
|
|
|
}
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|
2019-12-25 22:13:04 +08:00
|
|
|
|
|
|
|
<style>
|
|
|
|
[data-theme="dark"] .steps-content {
|
|
|
|
margin-top: 16px;
|
|
|
|
border: 1px dashed #303030;
|
|
|
|
background-color: rgba(255,255,255,0.04);
|
|
|
|
color: rgba(255,255,255,0.65);
|
|
|
|
padding-top: 80px;
|
|
|
|
}
|
|
|
|
</style>
|