出现后,问题在React-Native-WebView上返回False
在我的React-nigation项目中,我使用React-native-webview,实际上,我使用onshoundStartLoadWithRequest来验证URL请求。当URL等于我的变量时,onShoundStartLoadWithRequest返回true并正常加载URL,但是当URL等于我的变量时,我会显示警报和onshoundStartLoadWithRequest返回false。 当用户单击OK时,请在警报处导航,我会从我的应用登录页面导航,但是如果用户取消并留在页面上,请不要加载其他页面上的其他网址 基本上,好像在返回虚假到URL之后,OnShoundStartLoadWithRequest没有加载任何其他
我的代码:
function verifyurl(url) {
if (url == myvarUrl) {
alerta();
return false;
} else {
setNewUrl(url)
return true;
}
}
async function alerta() {
const response = await alert();
response && logOut();
}
//Verifica se existe item na pilha navegação e retira
function logOut() {
let canGoBack = navigation.canGoBack();
canGoBack ? navigation.goBack() : console.log('AGIU MAIS DE UMA VEZ');
}
/* ========================> Retorno de Visualização <======================== */
const Spinner = () => (
<View style={genericStyles.activityContainer}>
<ActivityIndicator size="large" color="#f29900" />
</View>
);
return (
<View style={genericStyles.containerWebView}>
<StatusBar backgroundColor={genericStyles.colors.BlueBg} barStyle={'light-content'} />
<WebView
source={{ uri: propriedade }}
ref={webViewRef}
originWhitelist={['*']}
allowsInlineMediaPlayback
javaScriptEnabled
scalesPageToFit
mediaPlaybackRequiresUserAction={false}
javaScriptEnabledAndroid
useWebkit
startInLoadingState={true}
cacheEnabled={false}
renderLoading={Spinner}
onShouldStartLoadWithRequest={(event) => {
return verifyurl(event.url)
}}
/>
</View>
)
开发环境
react: ^17.0.2 => 17.0.2
react-native: ^0.68.2 => 0.68.2
react-native-webview: 11.22.2
请帮助我!
In my React-Native project i use react-native-webview, actually i use onShouldStartLoadWithRequest to verify url requests. When url is equals my variable, the onShouldStartLoadWithRequest return true and load url normally, but, when url equals my variable i display alert and onShouldStartLoadWithRequest return false.
On alert when user click in ok i navigate from my app login page, but if user cancel and stay on page the webview dont load others urls ontened of page anymore
Basically, it's as if after returning false to a url, onShouldStartLoadWithRequest didn't load any other
My code:
function verifyurl(url) {
if (url == myvarUrl) {
alerta();
return false;
} else {
setNewUrl(url)
return true;
}
}
async function alerta() {
const response = await alert();
response && logOut();
}
//Verifica se existe item na pilha navegação e retira
function logOut() {
let canGoBack = navigation.canGoBack();
canGoBack ? navigation.goBack() : console.log('AGIU MAIS DE UMA VEZ');
}
/* ========================> Retorno de Visualização <======================== */
const Spinner = () => (
<View style={genericStyles.activityContainer}>
<ActivityIndicator size="large" color="#f29900" />
</View>
);
return (
<View style={genericStyles.containerWebView}>
<StatusBar backgroundColor={genericStyles.colors.BlueBg} barStyle={'light-content'} />
<WebView
source={{ uri: propriedade }}
ref={webViewRef}
originWhitelist={['*']}
allowsInlineMediaPlayback
javaScriptEnabled
scalesPageToFit
mediaPlaybackRequiresUserAction={false}
javaScriptEnabledAndroid
useWebkit
startInLoadingState={true}
cacheEnabled={false}
renderLoading={Spinner}
onShouldStartLoadWithRequest={(event) => {
return verifyurl(event.url)
}}
/>
</View>
)
Development environment
react: ^17.0.2 => 17.0.2
react-native: ^0.68.2 => 0.68.2
react-native-webview: 11.22.2
Please Help me!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论