All files / src/datepicker/_example DatePickerExample.jsx

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

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          1x                                                  
import React from "react";
import moment from "moment";
import { DatePicker } from "@tencent/tea-component/lib/datepicker";
 
export default () => {
  return (
    <>
      <section>
        <h3>日期选择</h3>
        <DatePicker
          defaultValue={moment("2019-04-01")}
          onChange={value => console.log(value.format("YYYY/MM/DD"))}
          onOpenChange={open => console.log(open ? "open" : "close")}
        />
      </section>
      <section>
        <h3>自定义 format 的日期选择</h3>
        <DatePicker
          format="LL"
          defaultValue={moment("2019-04-01")}
          onChange={value => console.log(value.format("YYYY/MM/DD"))}
        />
      </section>
      <section>
        <h3>包含时间的日期选择</h3>
        <DatePicker showTime onChange={value => console.log(value.format())} />
      </section>
    </>
  );
};