UNPKG

1.58 kBTypeScriptView Raw
1import { ComponentType } from 'react'
2import { StandardProps } from './common'
3interface LabelProps extends StandardProps {
4 /** 绑定控件的 id */
5 for?: string
6}
7
8/** 用来改进表单组件的可用性。
9 *
10 * 使用for属性找到对应的id,或者将控件放在该标签下,当点击时,就会触发对应的控件。 for优先级高于内部控件,内部有多个控件的时候默认触发第一个控件。 目前可以绑定的控件有:button, checkbox, radio, switch。
11 * @classification forms
12 * @supported weapp, swan, alipay, tt, h5, rn, harmony
13 * @example_react
14 * ```tsx
15 * class App extends Components {
16 *
17 * render () {
18 * return (
19 * <RadioGroup>
20 * <Label className='example-body__label' for='1' key='1'>
21 * <Radio value='USA'>USA</Radio>
22 * </Label>
23 * <Label className='example-body__label' for='2' key='2'>
24 * <Radio value='CHN' checked>
25 * CHN
26 * </Radio>
27 * </Label>
28 * </RadioGroup>
29 * )
30 * }
31 * }
32 * ```
33 * @example_vue
34 * ```html
35 * <template>
36 * <radio-group>
37 * <label class="example-body__label" for="1" key="1">
38 * <radio id="1" value="USA" />
39 * USA
40 * </label>
41 * <label class="example-body__label" for="2" key="2">
42 * <radio id="2" value="CHN" :checked="true" />
43 * CHN
44 * </label>
45 * </radio-group>
46 * </template>
47 * ```
48 * @see https://developers.weixin.qq.com/miniprogram/dev/component/label.html
49 */
50declare const Label: ComponentType<LabelProps>
51export { Label, LabelProps }