All files / src/select/_example SelectExample.jsx

33.33% Statements 3/9
100% Branches 0/0
14.29% Functions 1/7
33.33% Lines 3/9

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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81          1x               1x   1x                                                                                                                                  
import React, { useState } from "react";
import { Select } from "@tencent/tea-component/lib/select";
import { Form } from "@tencent/tea-component/lib/form";
import { Button } from "@tencent/tea-component/lib/button";
 
const options = [
  { value: "strawberry", text: "草莓", tooltip: "甜甜甜" },
  { value: "apple", text: "苹果", tooltip: "每日一苹果,医生远离我" },
  { value: "orange", text: "橙子", tooltip: "丰富 VC 含量" },
  { value: "durian", text: "榴莲", disabled: true, tooltip: "榴莲已售罄" },
];
 
export default function SelectExample() {
  const [favorite, setFavorite] = useState(null);
 
  return (
    <Form>
      <Form.Item label="原生下拉">
        <Select
          type="native"
          size="m"
          options={options}
          value={favorite}
          onChange={value => setFavorite(value)}
          placeholder="请选择你最爱的水果"
        />
      </Form.Item>
      <Form.Item label="模拟下拉">
        <Select
          type="simulate"
          appearance="default"
          options={options}
          value={favorite}
          onChange={value => setFavorite(value)}
          placeholder="请选择你最爱的水果"
        />
      </Form.Item>
      <Form.Item label="下拉按钮">
        <Select
          type="simulate"
          appearance="button"
          options={options}
          value={favorite}
          onChange={value => setFavorite(value)}
          placeholder="请选择你最爱的水果"
        />
      </Form.Item>
      <Form.Item label="下拉链接">
        <Select
          type="simulate"
          appearance="link"
          options={options}
          value={favorite}
          onChange={value => setFavorite(value)}
          placeholder="请选择你最爱的水果"
        />
      </Form.Item>
      <Form.Item label="筛选">
        <Select
          type="simulate"
          appearance="filter"
          options={options}
          value={favorite}
          onChange={value => setFavorite(value)}
          placeholder="请选择你最爱的水果"
        />
      </Form.Item>
      <Form.Item label="自定义">
        <Select
          type="simulate"
          appearance="pure"
          options={options}
          value={favorite}
          onChange={value => setFavorite(value)}
          button={<Button type="icon" icon="more" />}
        />
      </Form.Item>
    </Form>
  );
}