首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >按钮在模拟器上工作,但在smartphone上不工作

按钮在模拟器上工作,但在smartphone上不工作
EN

Stack Overflow用户
提问于 2022-04-20 09:47:20
回答 1查看 287关注 0票数 0

我已经有几天的问题了,我有一个项目清单(一个标题列表),我希望能够对这些项目采取行动(更新/删除)。

我创建了一个item组件,其中有一个“更新和删除”按钮。

Button组件是react本机元素的一个组件,我在我的应用程序中到处使用它,到目前为止我还没有遇到任何问题。

ThemeItem.tsx

代码语言:javascript
复制
    <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

代码语言:javascript
复制
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%;
`;

容器

代码语言:javascript
复制
const Container = styled.View`
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  background-color: white;
`;

在模拟器上,行为是预期的,但是当我在我的手机上安装apk时,它并不是绝对发生的。

我完全不明白为什么我的代码在模拟器上工作,而不是在真正的手机上工作。我假设如果在模拟器上没有问题,问题不是来自于代码。

预先感谢您的帮助

EN

回答 1

Stack Overflow用户

发布于 2022-04-20 11:55:38

但是按钮的类型是什么呢?按钮,TouchableOpacity,TouchableOpacityWithoutFeedback..。

另外,我建议将按钮从react本机手势处理程序更改为RectButton,只需在应用程序中使用本机按钮;)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71937524

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档