All files / src/badge/_example BadgeSegmentExample.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          1x   1x                                              
import React, { useState } from "react";
import { Segment } from "@tencent/tea-component/lib/segment";
import { Badge } from "@tencent/tea-component/lib/badge";
 
export default function BadgeSegmentExample() {
  const [value, setValue] = useState(2);
 
  return (
    <Segment
      value={value.toString()}
      onChange={value => setValue(parseInt(value, 10))}
      options={[
        { text: "1个月", value: "1" },
        { text: "2个月", value: "2" },
        {
          text: (
            <>
              3个月
              <Badge theme="warning" dark>
                8.8折
              </Badge>
            </>
          ),
          value: "3",
        },
        { text: "半年", value: "6" },
      ]}
    />
  );
}