import { Checkbox, CheckboxGroup, Text, View } from "@tarojs/components"; import Taro from "@tarojs/taro"; import { IProps } from "../../../@types/checkbox"; import ClCheckboxH5 from "./h5"; import { classNames, isWeApp } from "../../lib"; export default function ClCheckbox(props: IProps) { const colorClassName = props.color || "green"; const type = props.type === "form" ? "form" : ""; const shapeClassName = props.shape === "round" ? "round" : ""; const directionClassName = props.direction === "horizontal" ? "flex" : ""; const list = props.checkboxGroup ? props.checkboxGroup : []; const title = props.title; const checkboxComponent = list.map(item => ( {item.key ? {item.key} : ""} )); const formComponent = ( {title} {checkboxComponent} ); const change = e => { props.onChange && props.onChange(e.detail.value); }; const component = !isWeApp ? ( ) : ( {type === "form" ? ( formComponent ) : ( {checkboxComponent} )} ); return ( {component} ); } ClCheckbox.options = { addGlobalClass: true };