react-native - React Native Webview OnLoad 调用了两次

React native webview onLoad(), onLoadStart(), onLoadEnd() 都被调用了两次

在下面找到我的代码

<WebView
  source={{
    uri,
  }}
  // eslint-disable-next-line no-return-assign
  ref={ref => (this.webview = ref)}
  startInLoadingState
  style={{ marginTop: 0, flex: 1 }}
  renderLoading={() => this.displaySpinner()}
  javaScriptEnabled
  geolocationEnabled
  injectedJavaScript={setTimeoutInjection}
  onLoad={() => this.pageLoadEnd(renderTime)}
  onLoadStart={() => {
    Alert.alert('On load event', `Loading time : ${Date.now() - renderTime}`)
  }}
  onLoadEnd={() => {
    Alert.alert('On load event End', `Loading time : ${Date.now() - renderTime}`)
  }}
  sharedCookiesEnabled
  useWebKit
  onNavigationStateChange={this._onNavigationStateChange.bind(this)}
/>

我应该更改什么以使 onload() 事件只被调用一次?

最佳答案

我遇到了这个问题,结果证明是源属性中 uri 末尾缺少一个简单的“/”。

https://stackoverflow.com/questions/60876984/

相关文章:

django - 无法在 nginx docker 容器上使用 http2

react-native - 使用 Hermes 的 React native 应用程序崩溃并显示

reactjs - 将 Ant 设计表导出为 pdf 格式

angular - 类型 'arrayBuffer' 上不存在属性 'File'

asp.net - SignalR 协商阶段发生 CORS 错误

python-3.x - 重复的日志 Flask - Google Cloud Logging

javascript - 如何访问 react-image-gallery 中的 slideToIn

python - 无需安装即可导入 Python 库

swift - 分段选择器移除了可访问性

r - 为什么 clogit 和 bife 函数(均在 R 中)的结果不同?