在React Native中禁用放大WebView或react-native-wkwebview

时间:2018-03-06 00:08:50

标签: ios react-native wkwebview

有没有办法禁用WKWebView for iOS和WebView for android?我正在使用react-native-wkwebview-reborn。

1 个答案:

答案 0 :(得分:1)

在此meta中的webview棒中呈现的文档的头部:

<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />

示例:

<!doctype html>

<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
    </head>
    <body>

    </body>
</html>

您可以将此注入您的网页浏览。

const SCRIPT = `
const meta = document.createElement('meta');
meta.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0');
meta.setAttribute('name', 'viewport');
document.head.appendChild(meta);
`;

<WebView injectedJavaScript={SCRIPT} />