我正在App WebView中为我的App实施。我必须打开一些信息页面,并且必须基于Web视图中任何特定位置(包含不同类型的数据)的点击来获取一些数据。但是在iOS中,在加载任何URL onShouldStartLoadWithRequest
时会自动进行调用,这会导致在HTML内容中打开不同的URL。但它在Android中按预期工作。
<WebView
originWhitelist={["*"]}
style={style}
source={source}
showsVerticalScrollIndicator={showsVerticalScrollIndicator}
startInLoadingState={startInLoadingState}
javaScriptEnabled={true}
onShouldStartLoadWithRequest={request => {
return onLoadWebViewOnClick(request)
}}
/>
在此handleUrlNavigation中将处理任何单击操作的请求,但每次都会自动调用。我该如何处理?
react-native-webview项目上有关于此问题的讨论。希望此链接对您有所帮助:https://github.com/react-native-community/react-native-webview/issues/381#issuecomment-472105217