React native webView Ios端禁止手势放大

如果是加载静态资源html标签,需要写全整个html页面,如下:

const htmlContent = '<!DOCTYPE html><html><body>' +
            '<head>'+
            '<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">'+
            '</head>'+
            `${content}` +
            '<script>' +
            'window.οnlοad=function(){' +
            'var height = document.body.clientHeight;' +
            'window.location.hash = "#" + height;document["title"] = height;};' +
            'function _onclick(data) {WebViewBridge.send(data);}'+
            '</script>' +
            '</body></html>';

<webView source={{html:htmlContent}} 其他配置省略.../>

其中在head中加入:

<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">

这句话是关键。
同理,如果加载的是动态的html页面,也需要在该页面的head标签内加上这句话

发布了18 篇原创文章 · 获赞 6 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/unhappy_long/article/details/71176264
今日推荐