如何禁用 react-native-element 的复选框可触摸不透明度?

Muh*_*man 3 javascript react-native react-native-elements

实际上,我正在使用 react-native-element 设计语言。当我过去实现复选框时,它的行为就像我不想要的可触摸不透明度。

<CheckBox
  containerStyle={{ backgroundColor: "transparent", borderWidth: 0 }}
  center
  size={14}
  title="vegetarian"
  textStyle={{
    fontSize: theme.FONT_SIZE_X_SMALL,
    fontWeight: theme.FONT_WEIGHT_LIGHT
  }}
  checkedColor="red"
  checked={this.state.checked}
  onPress={() => this.setState({ checked: !this.state.checked })}
/>;

Run Code Online (Sandbox Code Playgroud)

col*_*nux 8

您可以传递一个Component道具(TouchableOpacity默认情况下),TouchableWithoutFeedback例如作为值。

<CheckBox
  Component={TouchableWithoutFeedback}
  containerStyle={{ backgroundColor: "transparent", borderWidth: 0 }}
  center
  size={14}
  title="vegetarian"
  textStyle={{
    fontSize: theme.FONT_SIZE_X_SMALL,
    fontWeight: theme.FONT_WEIGHT_LIGHT
  }}
  checkedColor="red"
  checked={this.state.checked}
  onPress={() => this.setState({ checked: !this.state.checked })}
/>;
Run Code Online (Sandbox Code Playgroud)