Switch 开关


API#

Switch 是状态切换的开关按钮组件。

Switch#

属性 说明 类型 默认值
onTintColor 设置开关打开的背景色 string
tintColor 设置开关关闭时的背景色 string
thumbTintColor 设置开关关闭时的背景色 string
disabled 开关是否可交互 boolean true
value //todo
onValueChange 值改变时调用此函数 event

代码演示


/** @jsx createElement */
import {createElement, Component} from 'weex-rx';
import { View, Text, Switch } from 'nuke-components';
import {mount} from 'nuke-mounter';


let App = class NukeDemoIndex extends Component {
    constructor() {
        super();
    }

    state = {
        trueSwitchIsOn: true,
        falseSwitchIsOn: false
    };
    render() {
        return (
        <View>

            <Switch onTintColor={'green'} tintColor={'#ffffff'} thumbTintColor={'blue'}
                onValueChange={(value) =>this.setState({falseSwitchIsOn: value})}
                value={this.state.falseSwitchIsOn}/>
            <Switch
                onValueChange={(value) =>this.setState({trueSwitchIsOn: value})}
                value={this.state.trueSwitchIsOn}/>
        </View>
    );
  }
}

mount(<App/>, mountNode);
mobile phone header