0

我有 react-native-web 项目。我遇到的一个问题是,当TouchableHighlight按下 a 时,所有子元素的填充都会被删除。

在触摸之前,检查器显示正确的填充,在触摸填充为 0 之后。我尝试将其包装Text在一个View组件中,然后也将其展开。

我在这里不知所措

const bS : ViewStyle = {
paddingTop: 5,
paddingLeft: 5,
paddingRight: 5,
paddingBottom: 5,

flexDirection: "column",
justifyContent: "center",
width: '100%',
height: '100%'
}

export default function TextButton(props: {title: string, onPress: () => any}) {

return <TouchableHighlight style={s.touch} underlayColor={'#000000'} onPress={props.onPress}>
  <View style={bS}>
    <Text>{props.title}</Text>
  </View>
  </TouchableHighlight>
}

编辑 按要求,我将代码添加到 CodeSandbox,但它工作得非常好! https://codesandbox.io/s/distracted-golick-uwl6f?fontsize=14

编辑 2Reactreact-native. React导入时问题消失react

4

0 回答 0