2
當webview加載無效的url時,我應該設置哪個屬性來顯示錯誤視圖?我嘗試renderError,它觸發控制檯消息,但沒有顯示視圖。React原生WebView加載錯誤處理
這裏的代碼:
<View style={styles.webview_body}>
<WebView
source={{uri:this.props.url}}
onNavigationStateChange={this.onNavigationStateChange.bind(this)}
renderError={this.loadError.bind(this)}
/>
</View>
//the fucntion which display the error message
loadError(){
console.log('loaded');
return (
<View>
<Text>
something goes wrong.
</Text>
</View>
)
}
這裏的屏幕截圖
[更新]正如我重新加載清除錯誤,有這顯示錯誤視圖的臨時狀態。
我們是否應該處理onError呢? – vijayst
我不確定哪些屬性是必需的。 – Klyment