亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

ReactNative Alert詳解及實(shí)例代碼

 更新時(shí)間:2016年10月08日 11:13:44   作者:順子_RTFSC  
這篇文章主要介紹了ReactNative Alert詳解及實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下

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ì)本站的支持!

相關(guān)文章

最新評(píng)論