ReactNative Alert詳解及實(shí)例代碼
Alert顧名思義一就是一個(gè)警告框,一般使用情況比如:退出登錄,清楚緩存,提示修改密碼等等。。。ReactNative中的Alert只有一個(gè)靜態(tài)方法alert()其中有四個(gè)參數(shù):標(biāo)題,信息,按鈕和按鈕類型 在Android按鈕至多有三個(gè) 下面是使用情況:
實(shí)例代碼:
/** * 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}}> <Text style={styles.text} onPress={()=> this.showOneAlert()}>One</Text> <Text style={styles.text} onPress={()=> this.showTwoAlert()}>Two</Text> <Text style={styles.text} onPress={()=> this.showThreeAlert()}>Three</Text> </View> ) } showOneAlert() { Alert.alert( 'Alert 標(biāo)題', '只有一個(gè)按鈕', [ /** * 注意參數(shù)名字一定不能錯(cuò) */ {text: '確定', onPress: ()=> console.log('點(diǎn)擊確定')} ]); } showTwoAlert() { Alert.alert( 'Alert 標(biāo)題', '兩個(gè)按鈕', [ {text: '確定', onPress: ()=> console.log('點(diǎn)擊確定')}, {text: '取消', onPress: ()=> console.log('點(diǎn)擊取消')} ] ); } showThreeAlert() { Alert.alert( 'Alert 標(biāo)題', '三個(gè)按鈕', [ //第一個(gè)和第二個(gè)按鈕的位置會(huì)顛倒 {text: '取消', onPress: ()=> console.log('點(diǎn)擊取消')}, {text: '確定', onPress: ()=> console.log('點(diǎn)擊確定')}, {text: '稍后', onPress: ()=> console.log('點(diǎn)擊稍后')}, ] ); } } const styles = StyleSheet.create({ text: { fontSize: 28 } }) module.exports = AlertG;
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
- Reactnative-iOS回調(diào)Javascript的方法
- ReactNative實(shí)現(xiàn)Toast的示例
- ReactNative中使用Redux架構(gòu)總結(jié)
- ReactNative 之FlatList使用及踩坑封裝總結(jié)
- ReactNative Image組件使用詳解
- ReactNative踩坑之配置調(diào)試端口的解決方法
- ReactNative短信驗(yàn)證碼倒計(jì)時(shí)控件的實(shí)現(xiàn)代碼
- ReactNative之鍵盤Keyboard的彈出與消失示例
- ReactNative-JS 調(diào)用原生方法實(shí)例代碼
- ReactNative頁(yè)面跳轉(zhuǎn)實(shí)例代碼
- 使用Win10+Android+夜神安卓模擬器,搭建ReactNative開(kāi)發(fā)環(huán)境
相關(guān)文章
Android底部菜單欄(RadioGroup+Fragment)美化
這篇文章主要介紹了Android底部菜單欄RadioGroup+Fragment美化,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-07-07Android實(shí)現(xiàn)ListView異步加載圖片的方法
這篇文章主要介紹了Android實(shí)現(xiàn)ListView異步加載圖片的方法,以實(shí)例形式較為詳細(xì)的分析了Android中ListView異步加載圖片的原理與相關(guān)實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-10-10android開(kāi)發(fā)教程之實(shí)現(xiàn)toast工具類
這篇文章主要介紹了android開(kāi)發(fā)中需要的toast工具類,需要的朋友可以參考下2014-05-05解決react-native軟鍵盤彈出擋住輸入框的問(wèn)題
這篇文章主要介紹了解決react-native軟鍵盤彈出擋住輸入框的問(wèn)題,本文通過(guò)實(shí)例圖文相結(jié)合給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-08-08android ListView和ProgressBar(進(jìn)度條控件)的使用方法
這篇文章主要介紹了android ListView控件的使用方法和ProgressBar(進(jìn)度條控件)的使用方法,代碼大家可以參考使用2013-11-11Android控件之SlidingDrawer(滑動(dòng)式抽屜)詳解與實(shí)例分享
這篇文章詳細(xì)介紹了Android控件之SlidingDrawer(滑動(dòng)式抽屜)與實(shí)例,有需要的朋友可以參考一下2013-10-10android實(shí)現(xiàn)自動(dòng)滾動(dòng)的Gallary控件效果
這篇文章主要介紹了android實(shí)現(xiàn)自動(dòng)滾動(dòng)的Gallary控件效果,涉及Android中Gallary控件的相關(guān)使用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-10-10Android 監(jiān)聽(tīng)Notification 被清除實(shí)例代碼
本文主要介紹Android 監(jiān)聽(tīng)Notification 事件,這里給大家提供實(shí)例代碼進(jìn)行參考,有需要的小伙伴可以參考下2016-07-07月下載量上千次Android實(shí)現(xiàn)二維碼生成器app源碼分享
既然是二維碼生成器那么我們?nèi)绾沃谱鞫S碼呢?這篇文章為大家分享了月下載量上千次Android實(shí)現(xiàn)二維碼生成器app源碼,希望大家喜歡2015-12-12