Welink React-ui表单组件Switch
【摘要】 Switch选择开关。Switch UI 提供与WeLink规范一致的视图。参数说明参数类型默认值说明checkedboolfalse是否打开onChangefunc-变更Switch状态事件import React from 'react';import { CellsTitle, CellBody, CellBodyExplan, CellFooter, Form, Form...
Switch
选择开关。Switch UI 提供与WeLink规范一致的视图。
参数说明
参数 | 类型 | 默认值 | 说明 |
---|---|---|---|
checked | bool | false | 是否打开 |
onChange | func | - | 变更Switch状态事件 |
import React from 'react';
import {
CellsTitle,
CellBody,
CellBodyExplan,
CellFooter,
Form,
FormCell,
Switch
} from '@wecode/react-weui';
class SwitchDemo extends React.Component {
state = {
checked: true,
checkedBody: true
};
handelChangeChecked=(key, e)=>{
this.setState({ [key]: e.target.checked });
}
render() {
const { checked, checkedBody } = this.state;
return (
<section>
<CellsTitle>Switch开关</CellsTitle>
<Form>
<FormCell switch>
<CellBody>主文体</CellBody>
<CellFooter>
<Switch checked={checked} onChange={e => this.handelChangeChecked('checked', e)} />
</CellFooter>
</FormCell>
<FormCell switch>
<CellBody>
主文体
<CellBodyExplan>此处是辅助说明文体,说明文本</CellBodyExplan>
</CellBody>
<CellFooter>
<Switch checked={checkedBody} onChange={e => this.handelChangeChecked('checkedBody', e)} />
</CellFooter>
</FormCell>
</Form>
</section>
);
}
}
export default SwitchDemo;
【版权声明】本文为华为云社区用户原创内容,未经允许不得转载,如需转载请自行联系原作者进行授权。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
作者其他文章
评论(0)