UNPKG

2.43 kBTypeScriptView Raw
1import { ComponentType } from 'react'
2import { StandardProps, CommonEventFunction, FormItemProps } from './common'
3interface CheckboxGroupProps extends StandardProps, FormItemProps {
4 /** 表单组件中加上 name 来作为 key
5 * @supported alipay, tt, h5, harmony_hybrid
6 */
7 name?: string
8 /** `<CheckboxGroup/>` 中选中项发生改变是触发 change 事件
9 * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
10 */
11 onChange?: CommonEventFunction<{
12 value: string[]
13 }>
14}
15/** 多项选择器,内部由多个checkbox组成
16 * @classification forms
17 * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
18 * @example
19 * ```tsx
20 * export default class PageCheckbox extends Component {
21 * state = {
22 * list: [
23 * {
24 * value: '美国',
25 * text: '美国',
26 * checked: false
27 * },
28 * {
29 * value: '中国',
30 * text: '中国',
31 * checked: true
32 * },
33 * {
34 * value: '巴西',
35 * text: '巴西',
36 * checked: false
37 * },
38 * {
39 * value: '日本',
40 * text: '日本',
41 * checked: false
42 * },
43 * {
44 * value: '英国',
45 * text: '英国',
46 * checked: false
47 * },
48 * {
49 * value: '法国',
50 * text: '法国',
51 * checked: false
52 * }
53 * ]
54 * }
55 * render () {
56 * return (
57 * <View className='page-body'>
58 * <View className='page-section'>
59 * <Text>默认样式</Text>
60 * <Checkbox value='选中' checked>选中</Checkbox>
61 * <Checkbox style='margin-left: 20rpx' value='未选中'>未选中</Checkbox>
62 * </View>
63 * <View className='page-section'>
64 * <Text>推荐展示样式</Text>
65 * {this.state.list.map((item, i) => {
66 * return (
67 * <Label className='checkbox-list__label' for={i} key={i}>
68 * <Checkbox className='checkbox-list__checkbox' value={item.value} checked={item.checked}>{item.text}</Checkbox>
69 * </Label>
70 * )
71 * })}
72 * </View>
73 * </View>
74 * )
75 * }
76 * }
77 * ```
78 * @see https://developers.weixin.qq.com/miniprogram/dev/component/checkbox-group.html
79 */
80declare const CheckboxGroup: ComponentType<CheckboxGroupProps>
81export { CheckboxGroup, CheckboxGroupProps }