小编Pay*_*tta的帖子

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)}
/>
Run Code Online (Sandbox Code Playgroud)

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

webview onload-event react-native

5
推荐指数
1
解决办法
4151
查看次数

标签 统计

onload-event ×1

react-native ×1

webview ×1