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> ); } }