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/