uniapp里使用web-view遮挡导航顶部问题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | <template> <view class = "page-web" > <uni-nav-bar left-icon= "back" :title= "title" left-text= "返回" @clickLeft= "navigateBack" statusBar= "true" ></uni-nav-bar> <view class = "page-inner" > <web-view :src= "url" ></web-view> </view> </view> </template> <script> export default { data() { return { url: '' , title: '加载中...' , } }, mounted() { }, methods: { navigateBack() { uni.navigateBack() } }, onReady() { // #ifdef APP-PLUS var wv; var height = 0; uni.getSystemInfo({ //成功获取的回调函数,返回值为系统信息 success: (sysinfo) => { height = sysinfo.windowHeight; //自行修改,自己需要的高度 此处如底部有其他内容,可以直接---(-50)这种 }, complete: () => {} }); var currentWebview = this .$scope.$getAppWebview() //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效 console.log(height) setTimeout(function() { wv = currentWebview.children()[0] wv.setStyle({top:70,height:height}) }, 1000); //如果是页面初始化调用时,需要延时一下 // #endif }, onLoad({ url, title }) { this .url = url this .title = title } } </script> <style> .page-web { flex: 1; width: 100%; flex-direction: column; } .page-inner { flex: 1; } </style> |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· Vue3状态管理终极指南:Pinia保姆级教程