You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.2 KiB

10 years ago
# 切换到下一步
10 years ago
- order: 3
9 years ago
随机生成 3~6 个步骤,初始随机进行到其中一个步骤。
10 years ago
10 years ago
---
````css
#components-steps-demo-step-next > div > div {
margin-bottom: 30px;
10 years ago
}
````
10 years ago
````jsx
var Steps = antd.Steps;
var Step = Steps.Step;
10 years ago
var container = document.getElementById('components-steps-demo-step-next');
var array = Array.apply(null, Array(Math.floor(Math.random() * 3) + 3));
var steps = array.map(function(item, i) {
return {
title: '步骤' + (i + 1)
};
});
10 years ago
var App = React.createClass({
10 years ago
getInitialState() {
return {
currentStep: Math.floor(Math.random() * steps.length)
}
},
next() {
10 years ago
var s = this.state.currentStep + 1;
if (s === steps.length) {
s = 0;
}
this.setState({
currentStep: s
});
},
render() {
var cs = this.state.currentStep;
return (
<div>
<div>当前正在执行第 {cs + 1} 步</div>
<Steps current={cs}>
{steps.map((s, i) => <Step key={i} title={s.title} description={s.description} />)}
</Steps>
<div>
<button className='ant-btn' onClick={this.next}>下一步</button>
</div>
</div>
);
10 years ago
}
});
React.render(<App />, container);
10 years ago
````