All files / src/pagination/_example PaginationExample.jsx

88.89% Statements 8/9
100% Branches 1/1
66.67% Functions 2/3
100% Lines 8/8

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          1x 1x 1x 1x 1x   1x                                             5x 5x    
import React, { useState } from "react";
import { Pagination } from "@tencent/tea-component/lib/pagination";
import { Switch } from "@tencent/tea-component/lib/switch";
 
export default function PaginationExample() {
  const s1 = useSwitch();
  const s2 = useSwitch();
  const s3 = useSwitch();
  const s4 = useSwitch();
  const s5 = useSwitch();
 
  return (
    <>
      <Pagination
        recordCount={1000}
        stateTextVisible={s1.value}
        pageSizeVisible={s2.value}
        pageIndexVisible={s3.value}
        jumpVisible={s4.value}
        endJumpVisible={s5.value}
      />
      <hr />
      <p>
        <Switch {...s1}>显示状态</Switch>
        <Switch {...s2}>显示页长</Switch>
        <Switch {...s3}>显示页码</Switch>
        <Switch {...s4}>显示翻页</Switch>
        <Switch {...s5}>显示头尾</Switch>
      </p>
    </>
  );
}
 
function useSwitch(defaultChecked = true) {
  const [value, onChange] = useState(defaultChecked);
  return { value, onChange: value => onChange(value) };
}