# 切换到下一步 - order: 3 随机生成 3~6 个步骤,初始随机进行到其中一个步骤。 --- ````css #components-steps-demo-step-next > div > div { margin-bottom: 30px; } ```` ````jsx var Steps = antd.Steps; var Step = Steps.Step; 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) }; }); var App = React.createClass({ getInitialState() { return { currentStep: Math.floor(Math.random() * steps.length) } }, next() { var s = this.state.currentStep + 1; if (s === steps.length) { s = 0; } this.setState({ currentStep: s }); }, render() { var cs = this.state.currentStep; return (
当前正在执行第 {cs + 1} 步
{steps.map((s, i) => )}
); } }); React.render(, container); ````