Switch

概述[开关]

<Switch /> 是一个开关组件。

注意:

<Switch /> 是一个单一子节点组件!


样例 1

export default class HomePage extends Widget<any, any> {
  state = {
    value1: true,
    value2: true,
    value3: true,
    value4: true
  };
  render() {
    return (
      <Page backgroundColor={Colors.Pagebg} appBar={<AppBar title="Switch 开关组件" />}>
        <Container>
          <Switch
            value={this.state.value1}
            activeColor={0xfffa871e}
            onChange={({ value }) => {
              this.setState({ ...this.state, value1: value });
            }}
          />
          <Switch
            value={this.state.value2}
            activeColor={0xfffc77ff}
            onChange={({ value }) => {
              this.setState({ ...this.state, value2: value });
            }}
          />
          <Switch
            value={this.state.value3}
            activeColor={0xffffc363}
            onChange={({ value }) => {
              this.setState({ ...this.state, value3: value });
            }}
          />
          <Switch
            value={this.state.value4}
            activeColor={0xffa3ff47}
            onChange={({ value }) => {
              this.setState({ ...this.state, value4: value });
            }}
          />
        </Container>
      </Page>
    );
  }
}

上述例子的效果图:

Last Updated:
Contributors: wangyong-debug
©深圳市酷开网络科技股份有限公司 ICP备案号粤ICP备06098778号