当单击网站中在新选项卡或新窗口中打开的任何链接时,WebView 在本机反应中会转到浏览器而不是覆盖 WebView

TP *_*NGH 1 native webview reactjs

在 React Native WebView 中,在 WebView 中,单击在新水龙头或新窗口中打开的链接时会出现问题,WebView 将我们的应用程序重定向到浏览器,但我希望应用程序不要重定向到浏览器,WebView 会覆盖该链接。请解决问题,我很为你着想......

当单击网站中的任何链接时,这些网站会从我们的 React Native 应用程序重定向到我们的浏览器

import React, { useState } from 'react';
import WebView from 'react-native-webview';

const App = () =>{

return(
<WebView
 source={{uri:"https://www.coeju.com"}}

 />
  );
}


export default App;
Run Code Online (Sandbox Code Playgroud)

atr*_*s01 6

setSupportMultipleWindows={false} 将其添加到您的 webview 属性中。如需了解其工作原理的更多信息,请访问以下链接。

https://github.com/react-native-webview/react-native-webview/blob/master/docs/Reference.md#setsupportmultiplewindows

<WebView
  {...restProps}
  source={{uri}}
  onLoadStart={()=>setloading(true)}
  onLoadEnd={()=>setloading(false)}
  onLoad={()=>setloading(false)}
  style={{ flex: 1 }}
  injectedJavaScript={INJECTEDJAVASCRIPT}
  scrollEnabled
  setSupportMultipleWindows={false} //This will solve your problem
>
Run Code Online (Sandbox Code Playgroud)