React Native Alert 功能不会触发
React Native Alert function won't triggered
我只是想做一个简单的教程来学习。我只是对授权进行编码以查看警告框,但我不能 运行。另外,我正在浏览器的 webview 中对其进行测试。
这是我的代码。
console.log('pressed');
console.log(this.state.mail);
console.log(this.state.password);
if (this.state.mail == 'test' && this.state.password == 123) {
console.log("successful");
}
else {
Alert.alert(
"Alert Title",
"My Alert Msg",
[
{
text: "Cancel",
onPress: () => console.log("Cancel Pressed"),
style: "cancel"
},
{ text: "OK", onPress: () => console.log("OK Pressed") }
]
);
console.log("failed");
}
}```
If part works correctly. In else part 'failed' log also works correctly but alert won't work.
据我搜索,React 本机警报组件无法在网络浏览器上运行。我用我的手机 phone 测试了它,发现它有效。
我只是想做一个简单的教程来学习。我只是对授权进行编码以查看警告框,但我不能 运行。另外,我正在浏览器的 webview 中对其进行测试。
这是我的代码。
console.log('pressed');
console.log(this.state.mail);
console.log(this.state.password);
if (this.state.mail == 'test' && this.state.password == 123) {
console.log("successful");
}
else {
Alert.alert(
"Alert Title",
"My Alert Msg",
[
{
text: "Cancel",
onPress: () => console.log("Cancel Pressed"),
style: "cancel"
},
{ text: "OK", onPress: () => console.log("OK Pressed") }
]
);
console.log("failed");
}
}```
If part works correctly. In else part 'failed' log also works correctly but alert won't work.
据我搜索,React 本机警报组件无法在网络浏览器上运行。我用我的手机 phone 测试了它,发现它有效。