All files / src/cascader/_example CascaderChangeExample.jsx

66.67% Statements 2/3
100% Branches 0/0
50% Functions 1/2
66.67% Lines 2/3

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      1x                                                                                                 1x                
import React from "react";
import { Cascader } from "@tencent/tea-component/lib/cascader";
 
const data = {
  title: "省份",
  options: [
    {
      label: "北京市",
      value: "bj",
      child: {
        title: "区县",
        options: [
          { label: "朝阳区", value: "cy" },
          { label: "海淀区", value: "hd" },
        ],
      },
    },
    {
      label: "上海市",
      value: "sh",
      child: {
        title: "区县",
        options: [
          { label: "徐汇区", value: "xh" },
          { label: "黄埔区", value: "hp" },
        ],
      },
    },
    {
      label: "广东省",
      value: "gd",
      child: {
        title: "城市",
        options: [
          {
            label: "深圳市",
            value: "sz",
            child: {
              title: "区县",
              options: [
                { label: "南山区", value: "ns" },
                { label: "宝安区", value: "ba" },
              ],
            },
          },
        ],
      },
    },
  ],
};
 
export default function CascaderExample() {
  return (
    <Cascader
      data={data}
      changeOnSelect
      onChange={(value, { options }) => console.log(value, options)}
    />
  );
}