Alert - 弹窗

通过 Alert.alert() 方法调用唤起原生弹窗,点击会触发 onPress 回调(参考下方代码)并清除弹窗。

import React, {
    AppRegistry,
    Component,
    StyleSheet,
    Alert,
    Text,
    View
} from 'react-native';

class AwesomeProject extends Component {
    componentDidMount(){
        Alert.alert(
            'Alert标题',
            '一些正文内容',
            [
                //{text: '稍后询问', onPress: () => console.log('Ask me later pressed')},
                //{text: '取消', onPress: () => console.log('Cancel Pressed')},
                {text: 'OK', onPress: () => console.log('OK Pressed')}
            ]
        )
    }
    render() {
        return (
            <View style={styles.container}>
                <Text style={styles.text}>
                    DEMO
                </Text>
            </View>
        );
    }
}
View Code

相关文章:

  • 2022-01-06
  • 2021-11-21
  • 2021-05-16
  • 2021-11-13
  • 2021-12-03
  • 2021-07-11
  • 2021-10-18
  • 2021-10-10
猜你喜欢
  • 2021-07-28
  • 2021-04-01
  • 2021-10-22
  • 2022-01-19
相关资源
相似解决方案