我具有以下组件,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"}/>
但是控制台中没有任何内容。缺什么 ?