这写的啥
这写的啥
  • 发布:2024-05-10 09:41
  • 更新:2024-05-10 09:41
  • 阅读:197

【报Bug打包结果与真机测试结果不同,使用方法让web-view适配各种屏幕,在真机测试的时候有效,打包安装使用的时候,web-view就会铺满屏幕,无法适配

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10

HBuilderX类型: 正式

HBuilderX版本号: 4.08

手机系统: Android

手机系统版本号: Android 14

手机厂商: 华为

手机机型: 华为平板

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

操作步骤:
        // #ifdef APP-PLUS  

            var currentWebview = this.$scope.$getAppWebview();  
            const query = uni.createSelectorQuery().in(this);  
                let topHeight = 0;  
                query.select('.header-top-bg').boundingClientRect((data) => {  
                    topHeight = data.height; // 头部元素高度  
                }).exec();  
                let hight = uni.getSystemInfoSync()  
                this.screenHeight = hight.screenHeight  
                console.log(this.screenHeight)  
                let mate = hight.screenHeight - 70  
                let wv = currentWebview.children()[0];  
                console.log(mate)  
                console.log(this.appHight)  
                this.$nextTick(() =>{  

                    wv.setStyle({top:topHeight,height: mate})  
                })  

            // #endif  

预期结果:

根据各种屏幕适配

实际结果:

没有效果

bug描述:

<template>  
    <view class="container">  
        <view class="main">  

        <web-view  :src="src"  class="webBox"></web-view>  

        </view>  
        <foot :current-page = "4" class="tabbar" v-if="footShow"></foot>  
    </view>  
</template>  

<script>  
    import footer from '../../component/footer.vue'  
    export default {  
        components:{  
            foot:footer  
        },  
        data() {  
            return {  
                src: 'https://www.720yun.com/vr/6ffjzzsukm0',  
                footShow:true,  
                screenHeight:''  

            }  
        },  
        mounted() {  

            this.$music.playBgm({mute:false})  
        },  
        onLaunch() {  
            uni.hideTabBar()  
        },  
        onShow() {  
            this.footShow = true  

        },  
        onHide() {  
        // this.footShow = false      
        },  
        async onReady(){  
            // #ifdef APP-PLUS  

            var currentWebview = this.$scope.$getAppWebview();  
            const query = uni.createSelectorQuery().in(this);  
                let topHeight = 0;  
                query.select('.header-top-bg').boundingClientRect((data) => {  
                    topHeight = data.height; // 头部元素高度  
                }).exec();  
                let hight = uni.getSystemInfoSync()  
                this.screenHeight = hight.screenHeight  
                console.log(this.screenHeight)  
                let mate = hight.screenHeight - 70  
                let wv = currentWebview.children()[0];  
                console.log(mate)  
                console.log(this.appHight)  
                this.$nextTick(() =>{  

                    wv.setStyle({top:topHeight,height: mate})  
                })  

            // #endif  
        },  
        methods: {  

        }  
    }  
</script>  

<style scoped>  
    .container {  
    display: flex;  
    flex-direction: column;  
    height: 100%;  
    width: 100%;  
    background-color: #052d3d;  

    }  
    .main{  
        height: 95%;  
        width: 100%;          
        flex: 1;  
    }  
    .tabbar{      
         width: 100%;         
        height: 70px;     
        z-index: 9;  
    }  
</style>
2024-05-10 09:41 负责人:无 分享
已邀请:

要回复问题请先登录注册