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