All files / src/datepicker/_example RangePickerExample.jsx

33.33% Statements 2/6
0% Branches 0/2
20% Functions 1/5
33.33% Lines 2/6

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        1x     1x                                                                  
import React from "react";
import moment from "moment";
import { DatePicker } from "@tencent/tea-component/lib/datepicker";
 
const { RangePicker } = DatePicker;
 
export default () => {
  return (
    <>
      <section>
        <h3>范围选择</h3>
        <RangePicker
          defaultValue={[moment("2019-02-14"), moment("2019-04-01")]}
          onChange={value =>
            console.log(
              value[0].format("YYYY/MM/DD"),
              value[1].format("YYYY/MM/DD")
            )
          }
          onOpenChange={open => console.log(open ? "open" : "close")}
        />
      </section>
      <section>
        <h3>包含时间的范围选择</h3>
        <RangePicker
          showTime
          onChange={value => console.log(value[0].format(), value[1].format())}
        />
      </section>
      <section>
        <RangePicker
          separator="至"
          format="YYYY-MM-DD HH:mm"
          showTime={{ format: "HH:mm" }}
          onChange={value => console.log(value[0].format(), value[1].format())}
        />
      </section>
    </>
  );
};