无法在React-Native的警报中设置警报框标题

时间:2016-05-26 18:05:48

标签: react-native

我无法使用React-Native

设置Alert框的标题
import React, { Component } from 'react';
import ReactNative,{
  StyleSheet,
  Text,
  View,
  Alert,
} from 'react-native';

...

alert("myTitle","my message");

标题显示为“警报”而不是“myTitle”

2 个答案:

答案 0 :(得分:9)

语法不同:

Alert.alert("myTitle", "my message");

参考:Strange Put Json form data (Jquery Ajax)

答案 1 :(得分:3)

 Alert.alert(
        'Alert Title',
        'My Alert Msg',
        [
          {text: 'Ask me later', onPress: () => console.log('Ask me later pressed')},
          {text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'},
          {text: 'OK', onPress: () => console.log('Ok Pressed')},
        ],
        { cancelable: false }
      )