--- order: 3 title: 切换到下一步 --- 随机生成 3~6 个步骤,初始随机进行到其中一个步骤。 ````jsx import { Steps, Button } from 'antd'; const Step = Steps.Step; const array = Array.apply(null, Array(Math.floor(Math.random() * 3) + 3)); const steps = array.map((item, i) => ({ title: `步骤${i + 1}`, })); const App = React.createClass({ getInitialState() { return { current: Math.floor(Math.random() * steps.length), }; }, next() { let current = this.state.current + 1; if (current === steps.length) { current = 0; } this.setState({ current }); }, render() { const { current } = this.state; return (
当前正在执行第 {current + 1} 步
{steps.map((s, i) => )}
); }, }); ReactDOM.render(, mountNode); ````