ios - 反应原生自定义按钮仅在 iOS 上不可点击
问题描述
我有以下组件,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"}/>
但是控制台中没有打印任何内容。什么不见了 ?
解决方案
推荐阅读
- python - 我有一个 python 列表作为字符串,我想将它打印为间隔和顺序
- http - 使用正则表达式将网页中的内容提取到变量中(WEB场景一步一步)
- google-bigquery - 需要通过 IR 连接 ADF 和 BigQuery
- node.js - 如何自动将环境变量应用到“npm install”过程?
- sql-server - 执行速度比 Sql OpenQuery 慢
- java - 如何拥有一个接受接口的构造函数?
- linux - CMake 错误“包含找不到加载文件:FetchContent”
- mysql - 有没有计算数据库中读取时间差的语句?
- ruby-on-rails - 如何在 ActiveAdmin 过滤器中重新排序选项列表项?
- php - Laravel:在一对多关系上选择不同