首页 > 其他分享 >【快应用】webview接口打开网页,网页会被自动放大,如何适配手机大小

【快应用】webview接口打开网页,网页会被自动放大,如何适配手机大小

时间:2022-08-16 10:23:09浏览次数:89  
标签:接口打开 网页 适配 https webview true

【现象描述】

通过webview接口打开网页,网页会被自动放大,问题代码如下:

webview.loadUrl({

url: 'https://cdn.langqing.club/jQuery/index.html',

allowthirdpartycookies: true

})

 

【问题分析】

原因在于快应用加载器没有对网页的比例和屏幕的宽度做适配,默认显示网页实际的宽度,没有将网页内容全部显示在屏幕宽度内。

 

【解决方法】

可以通过web组件加载网页,并设置overviewmodeinload属性为true规避此问题。代码如下:

<template>

<div class="container">

<web src="https://cdn.langqing.club/jQuery/index.html" overviewmodeinload="true"></web>

</div>

</template>

<style>

.container {

flex-direction: column;

}

</style>

<script>

module.exports = {

data: {

},

onInit() {

this.$page.setTitleBar({

text: 'menu',

textColor: '#ffffff',

backgroundColor: '#007DFF',

backgroundOpacity: 0.5,

menu: true

});

},

}

</script>

 

欲了解更多更全技术文章,欢迎访问https://developer.huawei.com/consumer/cn/forum/?ha_source=zzh

标签:接口打开,网页,适配,https,webview,true
From: https://www.cnblogs.com/developer-huawei/p/16590707.html

相关文章