0.2.1 • Published 9 years ago

tingle-on-off v0.2.1

Weekly downloads
5
License
MIT
Repository
github
Last release
9 years ago

tingle-on-off npm version

开关控件,类似 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 可用配置

配置项必填默认值功能/备注
classNameoptional-自定义样式类
onrequired-布尔值,表示当前初始化的时候按钮开或者关的状态
readOnlyoptionalfalse是否不能修改
onChangerequired-点击之后的回调函数

Links 相关链接