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 54 55 56 57 58 59 60 61 62 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import React, { useState, Fragment } from "react"; import { Jumper } from "@tencent/tea-component/lib/jumper"; import { Switch } from "@tencent/tea-component/lib/switch"; const curDay = 3; export default function JumperExample() { const [day, setDay] = useState(1); const maxDay = 5; let prevDisabled = false; let nextDisabled = false; let prevTitle = "前一天"; let nextTitle = "后一天"; const curTitle = "今天"; Eif (day === 1) { prevDisabled = true; prevTitle = "当前在第一天"; } else if (day === maxDay) { nextDisabled = true; nextTitle = "当前在最后一天"; } const jumperProps = { prevDisabled, nextDisabled, prevTitle, nextTitle, curTitle, isCurrent: day === curDay, onNext: () => setDay(day + 1), onPrev: () => setDay(day - 1), onCurrent: () => setDay(curDay), }; const [updown, setUpdown] = useState(false); const [noBordered, setNoBordered] = useState(false); return ( <Fragment> <Jumper showCurrent direction={updown ? "updown" : "leftright"} noBordered={noBordered} {...jumperProps} /> <p> 当前正在查看第 {day}/{maxDay} 天 </p> <section> <Switch value={updown} onChange={value => setUpdown(value)}> 使用上下箭头 </Switch> <Switch value={noBordered} onChange={value => setNoBordered(value)}> 无边框样式 </Switch> </section> </Fragment> ); } |