当彼此相邻时,React-Native TouchableHighlight激活错误的按钮

时间:2018-09-25 15:50:10

标签: react-native react-native-ios touchableopacity touchablehighlight

我有一个React-Native视图,我必须将按钮彼此并排放置。

发生的事情是,当我单击返回时,它会执行应做的操作:console.log(-1)

但是,当我单击 Next 时,“返回”的console.log几乎被激活了70%,而只有30%的时间显示了{{1 }}

我不知道为什么会这样。这是渲染内容的屏幕截图。左侧是您从下面的代码中看到的内容,右侧是如果我在console.log(+1)上添加了红色边框,则会看到的内容。

styles.footerButtonContainer
  

甚至更奇怪的是,如果我添加了这个边框,那么上述问题将完全消失,并且按钮将按预期的方式工作。

enter image description here


代码

footerButtonContainer: {
  flex: 1,
  flexWrap: 'wrap', 
  alignItems: 'flex-start', 
  justifyContent: 'center',
  flexDirection:'row',
  borderWidth:1,
  borderColor:"red"
},

1 个答案:

答案 0 :(得分:0)

您的代码缺少最后一个关闭视图标记(</View>)。我在博览会上运行您的代码,看来它可以正常工作:

https://snack.expo.io/HJBsAIOFQ