我无法用React Native设置alert 框的标题

import React, { Component } from 'react';
import ReactNative,{
  StyleSheet,
  Text,
  View,
  Alert,
} from 'react-native';

...

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

标题显示为"alert ",而不是"我的标题"

推荐答案

语法不同:

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

参考:http://facebook.github.io/react-native/docs/alert.html#examples

React-native相关问答推荐

ITMS—91053:缺少API声明—ReactNative

如何在使用嵌套的堆栈导航器在选项卡之间导航后弹出到堆栈顶部?

如何在 Recompose 中使用 withHandlers 将 refs 添加到功能组件并在 ScrollView 上调用 ScrollTo?

IntelliSense 在第一项后无法在 React Native 样式表中工作

设置 rootView.appProperties 不会重新渲染根组件

使用 Hooks 在功能组件中react-navigation 标题

命令失败:gradlew.bat installDebug error whenever installing dependencies like navigation, firebase, icons etc in React-Native

如何在 React Native cli 中获取 SHA-1 密钥?

java.lang.ClassNotFoundException:在路径上找不到类.MainActivity:DexPathList react-native

React-Native: measure测量一个视图

获取没有地理位置 API React-native 的国家/城市?

在关闭 react-native 时更改 Switch 的 colored颜色

任务在 react-native 中因请求而成为orphaned - 这是什么意思?

React Native:当我从 XCode 运行应用程序时看不到 console.logs

Ipad 上的 React Native - 错误 - could not connect to development server

在 React Native 中使用小数

React Native 不支持在 Windows 上开发?

在不使用 3rd 方库的情况下,在react-native中显示主屏幕之前显示启动画面

安卓启动问题:Unsupported class file major version 57

React Native:无法解析模块 fs