React Native自定义按钮仅在iOS上不可单击

时间:2019-10-07 20:09:07

标签: ios react-native

我具有以下组件,onPress方法可在Android上完美运行,而在iOS中无法正常运行

export default class Tag extends React.PureComponent {

static propTypes = {
  title: PropTypes.string,
  accessibilityLabel: PropTypes.string,
  width: PropTypes.string,
  onPress: PropTypes.func,
  borderColor: PropTypes.string,
  backgroundColor: PropTypes.string,
  color: PropTypes.string
};

static defaultProps = {
  marginTop: 0,
  secureTextEntry: false,
  autoCapitalize: 'none',
  backgroundColor: "white",
  color: "black",
  marginLeft: 0
}

render() {
  const { onPress } = this.props;

  return (
    <TouchableHighlight onPress={onPress}style={[styles.tag, { backgroundColor: this.props.backgroundColor, marginLeft: this.props.marginLeft}]}>
      <Text style={{color: this.props.color, fontWeight:"bold", fontSize:15}}>{this.props.value}</Text>
  </TouchableHighlight>
);
}
}

  const styles = StyleSheet.create({
  tag: {
    padding: 5,
    color: 'white',
    borderRadius: 5,
    marginTop: 5,
  },
  });

我这样使用它:

<Tag onPress={() => console.log("TEST TEST")} marginLeft={0} value={"EDIT"}/>

但是控制台中没有任何内容。缺什么 ?

0 个答案:

没有答案