我已经有几天的问题了,我有一个项目清单(一个标题列表),我希望能够对这些项目采取行动(更新/删除)。
我创建了一个item组件,其中有一个“更新和删除”按钮。

Button组件是react本机元素的一个组件,我在我的应用程序中到处使用它,到目前为止我还没有遇到任何问题。
ThemeItem.tsx
<Container>
<List onPress={() => onSelectTheme(theme.id)}>
<ListItem.Content>
<View
style={{display: 'flex', flexDirection: 'row', marginBottom: 5}}>
<ListItem.Title style={{fontSize: 18, fontWeight: 'bold'}}>
{theme.name}
</ListItem.Title>
{isActive && (
<Icon
name={'check-circle'}
color={'green'}
style={{marginLeft: 5}}
size={20}
/>
)}
</View>
</ListItem.Content>
</List>
<ThemeItemIconsStyle>
<>
{theme.id > 1 && !isActive && (
<Button
onPress={() => onDelete(theme.id)}
icon={{
name: 'trash',
type: 'font-awesome-5',
size: 25,
color: 'white',
}}
/>
)}
<Button
onPress={() => onUpdate(theme)}
icon={{
name: 'pen',
type: 'font-awesome-5',
size: 25,
color: 'white',
}}
/>
</>
</ThemeItemIconsStyle>
</Container>ThemeItemIconStyle
const ThemeItemIconsStyle = styled.View`
display: flex;
flex-direction: row;
justify-content: space-around;
align-items: center;
padding: 15px 20px;
background-color: white;
width: 40%;
height: 100%;
`;容器
const Container = styled.View`
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
background-color: white;
`;在模拟器上,行为是预期的,但是当我在我的手机上安装apk时,它并不是绝对发生的。
我完全不明白为什么我的代码在模拟器上工作,而不是在真正的手机上工作。我假设如果在模拟器上没有问题,问题不是来自于代码。
预先感谢您的帮助
发布于 2022-04-20 11:55:38
但是按钮的类型是什么呢?按钮,TouchableOpacity,TouchableOpacityWithoutFeedback..。
另外,我建议将按钮从react本机手势处理程序更改为RectButton,只需在应用程序中使用本机按钮;)
https://stackoverflow.com/questions/71937524
复制相似问题