![](/img/trans.png)
[英]How do you achieve the below code in react-native when user presses a button
[英]I need to show error when user presses escape on prompt box , but code below doesnt seem to work, any answers?
function(catchError) {
try {
var firstname = prompt("please enter your first name");
}
catch (error) {
alert(error.message);
}}
1.如何解決此問題
2也可以在谷歌瀏覽器中使用
如果取消或按退出鍵, prompt
將返回null
。 只需檢查一下:
var firstname = prompt("please enter your first name");
if(firstname !== null) {
} else {
// ESC or cancel pressed
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.