ReactNative(API)Alert
生活随笔
收集整理的這篇文章主要介紹了
ReactNative(API)Alert
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
轉載:http://blog.csdn.net/u014360817/article/details/52510966
Alert顧名思義一就是一個警告框,一般使用情況比如:退出登錄,清楚緩存,提示修改密碼等等。。。ReactNative中的Alert只有一個靜態方法alert()其中有四個參數:標題,信息,按鈕和按鈕類型 在Android按鈕至多有三個 下面是使用情況:
/*** Created by Administrator on 2016/9/12.*/ import React, {Component} from 'react'; import {StyleSheet,View,Text,Alert, } from 'react-native';class AlertG extends Component {render() {return (<View style={{flex: 1}}><Textstyle={styles.text}onPress={()=> this.showOneAlert()}>One</Text><Textstyle={styles.text}onPress={()=> this.showTwoAlert()}>Two</Text><Textstyle={styles.text}onPress={()=> this.showThreeAlert()}>Three</Text></View>)}showOneAlert() {Alert.alert('Alert 標題','只有一個按鈕',[/*** 注意參數名字一定不能錯*/{text: '確定', onPress: ()=> console.log('點擊確定')}]);}showTwoAlert() {Alert.alert('Alert 標題','兩個按鈕',[{text: '確定', onPress: ()=> console.log('點擊確定')},{text: '取消', onPress: ()=> console.log('點擊取消')}]);}showThreeAlert() {Alert.alert('Alert 標題','三個按鈕',[//第一個和第二個按鈕的位置會顛倒{text: '取消', onPress: ()=> console.log('點擊取消')},{text: '確定', onPress: ()=> console.log('點擊確定')},{text: '稍后', onPress: ()=> console.log('點擊稍后')},]);} }const styles = StyleSheet.create({text: {fontSize: 28} })module.exports = AlertG;總結
以上是生活随笔為你收集整理的ReactNative(API)Alert的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ReactNative-触摸事件
- 下一篇: 阿里云服务器的安装以及使用