0.2.1 • Published 9 years ago
tingle-on-off v0.2.1
tingle-on-off
开关控件,类似 iPhone 的开关。
Install
npm install tingle-on-off --save
Simple Usage
class Demo extends React.Component {
constructor(props) {
super(props);
this.state = {
on1: true,
on2: false,
on3: false
}
}
handleChange(form, on) {
this.setState({
[form]: on
});
}
render() {
return (
<div>
<OnOff on={this.state.on1} onChange={this.handleChange.bind(this, "on1")}/>
<OnOff on={this.state.on2} onChange={this.handleChange.bind(this, "on2")}/>
<OnOff on={this.state.on3} readOnly={true} onChange={this.handleChange.bind(this, "on3")}/>
</div>
);
}
}
Options 可用配置
配置项 | 必填 | 默认值 | 功能/备注 |
---|---|---|---|
className | optional | - | 自定义样式类 |
on | required | - | 布尔值,表示当前初始化的时候按钮开或者关的状态 |
readOnly | optional | false | 是否不能修改 |
onChange | required | - | 点击之后的回调函数 |