Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 当我使用Alert.Alert()时,expo将关闭_Ios_React Native_Expo - Fatal编程技术网

Ios 当我使用Alert.Alert()时,expo将关闭

Ios 当我使用Alert.Alert()时,expo将关闭,ios,react-native,expo,Ios,React Native,Expo,描述 我有一个提交按钮,我使用这个功能来处理响应。当我使用Alert.Alert()api时,它会自动关闭expo而不发出任何警告 预期行为 我希望看到模拟器上弹出一个警报 你采取了什么行动,你预期会发生什么 观察到的行为 世博会立即在手机或模拟器上闭幕 环境 Expo CLI 3.13.1环境信息: 系统: 操作系统:macOS 10.15.3 外壳:5.7.1-/bin/zsh 二进制文件: 节点:12.14.0-/usr/local/bin/Node 纱线:1.21.1-/usr/loca

描述

我有一个提交按钮,我使用这个功能来处理响应。当我使用Alert.Alert()api时,它会自动关闭expo而不发出任何警告

预期行为

我希望看到模拟器上弹出一个警报 你采取了什么行动,你预期会发生什么

观察到的行为

世博会立即在手机或模拟器上闭幕

环境

Expo CLI 3.13.1环境信息: 系统: 操作系统:macOS 10.15.3 外壳:5.7.1-/bin/zsh 二进制文件: 节点:12.14.0-/usr/local/bin/Node 纱线:1.21.1-/usr/local/bin/纱线 npm:6.13.7-/usr/local/bin/npm 看守人:4.9.0-/usr/local/bin/Watchman IDE: 安卓工作室:3.5AI-191.8026.42.35.6010548 Xcode:11.3.1/11C504-/usr/bin/Xcode构建 NPM包装: 世博会:^36.0.0=>36.0.2 反应:16.9.0=>16.9.0 反应本机:=>0.61.4 npmGlobalPackages: 博览会cli:3.13.1

iPhone11模拟器和expo物理版iPhoneX

可复制演示

import {Alert, Button, } from 'react-native';
const submitButton =  () => {
    Alert.alert('error', [{ text: 'Ok' }]);
 }

//inside return func
<Button title="Submit" onPress={submitButton} />
从'react native'导入{Alert,Button,};
const submitButton=()=>{
Alert.Alert('error',[{text:'Ok'}]);
}
//内部返回函数

它崩溃了,因为您没有传递“消息”。无论消息是否为空,你都必须写它

    syntax of Alert :- static alert(title, message?, buttons?, options? type?)

    yes. we knew that message Parameter is optional , but still you have to pass it when you use Alert.alert(), might be it is expo error . 
1) 解决方案

2) 解决方案

const submitButon = () => {
    alert('error', [{ text: 'Ok' }]);
}

It will solved your problem 
const submitButon = () => {
    alert('error', [{ text: 'Ok' }]);
}

It will solved your problem