其他分享
首页 > 其他分享> > 【UNI-APP】跳转外部链接 保留顶部

【UNI-APP】跳转外部链接 保留顶部

作者:互联网

<template>
    <view class="">
        <HeadBar title="标题" background_b="#f3212a" color="black" leftbtnclass="gc-000"></HeadBar>
        <web-view src="外部链接"></web-view>
    </view>
</template>
// 跳转外部链接 保留顶部
            getsize() {
                var height = 0; //定义动态的高度变量,如高度为定值,可以直接写
                uni.getSystemInfo({
                    //成功获取的回调函数,返回值为系统信息
                    success: (sysinfo) => {
                        height = sysinfo.windowHeight; //自行修改,自己需要的高度 此处如底部有其他内容,可以直接---(-50)这种
                    },
                    complete: () => {}
                });
                var currentWebview = this.$scope.$getAppWebview(); //获取当前web-view
                setTimeout(function() {
                    var wv = currentWebview.children()[0];
                    wv.setStyle({ //设置web-view距离顶部的距离以及自己的高度,单位为px
                        top: 68, //此处是距离顶部的高度,应该是你页面的头部
                        height: height
                    })
                }, 1000); //如页面初始化调用需要写延迟
            },
onLoad() {
            that = this
            this.getsize()()

        },

 

标签:顶部,APP,高度,height,跳转,var,UNI,currentWebview
来源: https://www.cnblogs.com/wanghong1994/p/14587440.html