其他分享
首页 > 其他分享> > android – 如何在反应原生中缩小WebView?

android – 如何在反应原生中缩小WebView?

作者:互联网

我在react-native中使用“WebView”来呈现网页.该网页没有适合移动设备的用户界面.

当我在Chrome浏览器中打开它时,它看起来如下所示.而且我想要下面这样

enter image description here

但是当我在代码下面渲染时,它看起来像下面显示的图像.
请注意我已尝试过不同的道具自动调整内容= {false},scalesPageToFit = {false}.但它没有给我欲望输出.

render(){
    const URL  = "https://stellarterm.com";
    return(
          <WebView 
             source={{URL}}
          />

结果

enter image description here

如果有,请随时提出任何解决方案.任何第三方图书馆也都可以.

解决方法:

您的网站已在meta中设置了网页宽度< meta name =“viewport”content =“width = 1080”>

因此,您需要使用injectJavaScript覆盖它

injectJavaScript = {`const meta = document.createElement(‘meta’); meta.setAttribute(‘content’,’width = device-width,initial-scale = 0.5,maximum-scale = 0.5,user-scalable = 0′); meta.setAttribute(‘name’,’viewport’); document.getElementsByTagName( ‘头’)[0] .appendChild(甲基); `}
scalesPageToFit = {FALSE}

标签:android,reactjs,react-native,webview,react-native-android
来源: https://codeday.me/bug/20191009/1877346.html