0.2.1 • Published 9 years ago

tingle-on-off-field v0.2.1

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

tingle-on-off-field npm version

The OnOffField Component for tinglejs

Install

npm install tingle-on-off-field --save

Simple Usage

class Demo extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            on: true,
            on1: false,
            on2: true,
            on3: false
        }
    }

    handleChange(key,value) {
        this.setState({
            [key]: value
        })
    }
    render() {
        return (
            <div>
                 <GroupList title="开关控件">
                    <OnOffField label="默认选中" on={this.state.on} onChange={this.handleChange.bind(this,'on')}/>
                    <OnOffField label="默认没选中" on={this.state.on1} onChange={this.handleChange.bind(this,'on1')}/>
                    <OnOffField label="不可选" on={this.state.on2} readOnly={true} onChange={this.handleChange.bind(this,'on2')}/>
                    <OnOffField label="不可选" on={this.state.on3} readOnly={true} onChange={this.handleChange.bind(this,'on3')}/>
                </GroupList>
            </div>
        );
    }
};

Options 可用配置

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

Links 相关链接