WebView当错误的网址发出警告时

时间:2017-05-22 04:55:28

标签: webview react-native

我正在使用webview,当我提供错误的网址时,它会给warnig我想删除这个warnig并且只显示在本地未找到的页面 我的代码是

<WebView style={{flex:1,margin:20}}
  ref={WebView_Ref}
  source={{uri: 'https://www.gooef.com'}}
/>

我想在上面的url webview显示只找到页面没有给出warnig Err_connection_refused url错误

1 个答案:

答案 0 :(得分:0)

使用renderError道具。

const errorPage = () =>{
  return (
    <Text>{'page not found '}</Text>
  )
}


//..
<WebView 
  renderError={errorPage}
  style={{flex:1,margin:20}}
  ref={WebView_Ref}
  source={{uri: 'https://www.gooef.com'}}
/>