123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <template>
- <view class="content">
- <view class="status_bar">
- <!-- 这里是状态栏 -->
- </view>
- <web-view :src="url" :fullscreen='false'></web-view>
- </view>
- </template>
- <script>
- var wv
- export default {
- data() {
- return {
- title: 'ehsd',
- url: 'http://106.54.243.161:10010/#/',
- src: "",
- canBack: false,
- }
- },
- onBackPress() {
- if (wv && this.canBack) {
- wv.back();
- return true;
- }
- return false;
- },
- onReady() {
- // #ifdef APP-PLUS
- var self = this;
- 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.addEventListener(
- "progressChanged",
- function(e) {
- wv.canBack(function(e) {
- self.canBack = e.canBack;
- });
- },
- false
- );
- }, 500); //如果是页面初始化调用时,需要延时一下
- // #endif
- },
- onLoad() {
- var height = 0; //定义动态的高度变量,如高度为定值,可以直接写
- uni.getSystemInfo({
- //成功获取的回调函数,返回值为系统信息
- success: (sysinfo) => {
- console.log(sysinfo)
- height = sysinfo.windowHeight; //自行修改,自己需要的高度 此处如底部有其他内容,可以直接---(-50)这种
- },
- complete: () => {}
- });
- let info = uni.getSystemInfoSync();
- let top = info.statusBarHeight;
- console.log(info, 12312312312);
- var currentWebview = this.$scope.$getAppWebview(); //获取当前web-view
- setTimeout(function() {
- var wv = currentWebview.children()[0];
- wv.setStyle({ //设置web-view距离顶部的距离以及自己的高度,单位为px
- top: top, //此处是距离顶部的高度,应该是你页面的头部
- // bottom:0,//防止输入框被软键盘遮挡
- height: height - top, //webview的高度
- scalable: false, //webview的页面是否可以缩放,双指放大缩小
- })
- // wx.setTitleNViewButtonStyle({
- // index:0,
- // styles:{
- // type:'back'
- // }
- // })
- }, 1000);
- methods: {
- }
- }
- }
- </script>
- <style>
- .content {}
- .status_bar {
- height: var(--status-bar-height);
- width: 100%;
- }
- </style>sss
|