onShouldStartLoadWithRequest在加载WebView中的任何URL时在iOS React Native中自动调用,如何控制它?

问题描述 投票:0回答:1

我正在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中将处理任何单击操作的请求,但每次都会自动调用。我该如何处理?

ios react-native react-native-ios react-native-webview
1个回答
0
投票

react-native-webview项目上有关于此问题的讨论。希望此链接对您有所帮助:https://github.com/react-native-community/react-native-webview/issues/381#issuecomment-472105217

© www.soinside.com 2019 - 2024. All rights reserved.