Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 1x 1x 2x 1x 1x 1x | import React, { useState } from "react"; import { Stepper } from "@tencent/tea-component/lib/stepper"; import { Button } from "@tencent/tea-component/lib/button"; export default function StepperExample() { const steps = [ { id: "prepare", label: "验证备案类型" }, { id: "info", label: "填写备案信息" }, { id: "upload", label: "上传资料" }, { id: "photo", label: "办理拍照" }, { id: "finish", label: "完成备案" }, ]; const [current, setCurrent] = useState("info"); const currentIndex = current ? steps.findIndex(x => x.id === current) : -1; const next = current && steps[currentIndex + 1]; const prev = current ? steps[currentIndex - 1] : steps[steps.length - 1]; return ( <div> <Stepper steps={steps} current={current} /> <section style={{ textAlign: "center" }}> <div style={{ height: 100, lineHeight: "100px", textAlign: "center", background: "#f6f6f6", margin: "20px 0", }} > {steps[currentIndex] ? steps[currentIndex].label : "已完成"} </div> <Button disabled={!prev} onClick={() => setCurrent(prev.id)} tooltip={prev ? `上一步:${prev.label}` : "已经在第一步"} > 上一步 </Button> <Button type="primary" disabled={!next && !current} onClick={() => setCurrent(next ? next.id : null)} style={{ marginLeft: 10 }} > {next ? `下一步:${next.label}` : "完成"} </Button> </section> </div> ); } |