cjd-parkball
Version:
> 中后台业务组件库,中后台就像公园,进入需要买门票(登录),所以以 Parkball(公园球) 命名,公园内必定捕获!作为一个组件库,提供使用方法文档,方便开发者的调用
44 lines (31 loc) • 827 B
Markdown
---
category: 2
title: 可选择
title_en: Checkable
---
zh-CN
可通过 `CheckableTag` 实现类似 Checkbox 的效果,点击切换选中效果。
> 该组件为完全受控组件,不支持非受控用法。
en-US
`CheckableTag` works like Checkbox, click it to toggle checked state.
> it is an absolute controlled component and has no uncontrolled mode.
````jsx
import { Tag } from 'parkball';
const { CheckableTag } = Tag;
class MyTag extends React.Component {
state = { checked: true };
handleChange = (checked) => {
this.setState({ checked });
}
render() {
return <CheckableTag {...this.props} checked={this.state.checked} onChange={this.handleChange} />;
}
}
ReactDOM.render(
<div>
<MyTag>Tag1</MyTag>
<MyTag>Tag2</MyTag>
<MyTag>Tag3</MyTag>
</div>,
mountNode);
````