【问题标题】:React Native, TouchableOpacity alert get nothingReact Native,TouchableOpacity 警报一无所获
【发布时间】:2020-10-12 15:14:37
【问题描述】:

当我单击按钮打开切换时,它工作正常,但是当我想单击以显示警报时,我什么也得不到。任何想法

 <View style={[styles.container, this.props.style]}>

            <TouchableWithoutFeedback>
                <Animated.View style={[styles.button, styles.menu, Epargne]}>
                    <Text style={{ color: '#fff' }} >  Epargne  </Text>
                </Animated.View>
            </TouchableWithoutFeedback>

            <TouchableWithoutFeedback>
                <Animated.View style={[styles.button, styles.menu, Essentials]}>
                    <Text style={{ color: '#fff', paddingBottom: 15, paddingLeft: 5 }} >  Essentials  </Text>
                </Animated.View>
            </TouchableWithoutFeedback>

            <TouchableWithoutFeedback onPress={() => Alert.alert('saveIconn')}>
                <Animated.View style={[styles.button, styles.menu, Plaisirs]}>
                    <Text style={{ color: '#fff', padding: 11 }} >  Petits Plaisirs  </Text>
                </Animated.View>
            </TouchableWithoutFeedback>

            <TouchableWithoutFeedback onPress={this.toggleMenu}>
                <Animated.View style={[rotation]}>
                    <Image
                        style={{ width: 90, height: 110, padding: 50, paddingLeft: 80 }}
                        source={require('../assets/budget.jpg')}
                    />
                    <Text style={{ color: '#000', padding: 11 }} > Gerer mon Budget </Text>
                </Animated.View>
            </TouchableWithoutFeedback>
        </View>

【问题讨论】:

  • 您导入了Alert 组件吗?另外,尝试使用全局方法alert()。
  • 您是在网页端还是移动应用 android/ios 上查看结果?
  • 在我的安卓手机上

标签: react-native alert floating-action-button onpress touchablewithoutfeedback


【解决方案1】:

这可能会有所帮助

showAlert = () => {
 Alert.alert('saveIconn')
}

<TouchableWithoutFeedback onPress={this.showAlert}>
    <Animated.View style={[styles.button, styles.menu, Plaisirs]}>
      <Text style={{ color: '#fff', padding: 11 }} >  Petits Plaisirs  </Text>
    </Animated.View>
</TouchableWithoutFeedback>

【讨论】:

  • Alert.alert('saveIconn')}> 我认为问题就在这里,因为当我点击时我什么也得不到。
猜你喜欢
  • 1970-01-01
  • 2018-09-11
  • 2020-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-05
相关资源
最近更新 更多