<template>
<view>
<web-view src="https://www.baidu.com"></web-view>
</view>
</template>
<script>
var wv;//计划创建的webview
export default {
onReady() {
// #ifdef APP-PLUS
var currentWebview = this.$scope.$getAppWebview() //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效,非v3编译模式使用this.$mp.page.$getAppWebview()
setTimeout(function() {
wv = currentWebview.children()[0]
wv.setStyle({top:150,height:300})//top,height等都可以设置,不能带单位
}, 1000); //如果是页面初始化调用时,需要延时一下
// #endif
}
};
</script>
web-view禁止自动铺满全屏(仅限app)
最新推荐文章于 2024-07-31 16:06:03 发布