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

标签 react-native webview onload-event

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 末尾缺少一个简单的“/”。

关于react-native - React Native Webview OnLoad 调用了两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60876984/

相关文章:

javascript - 我怎样才能用 Jest 来遵守这个组件测试

react-native - 世博会 + 排毒 + CircleCI

Android: 有没有人有webview screen fit 的好方法?

javascript - Android webview如何使用webkit?

Javascript - onload 事件

android - 在模拟器中启动应用程序后,'React native run android' 立即停止

javascript - 如何在 React Native 中使用变量 'document'?

javascript - 如何修复“我们正在等待 WebCore 对着陆的响应时错过了拖累”

dom - window.onload 似乎在加载 DOM 之前触发(JavaScript)

javascript - IFrame 主体加载时未定义值