- 发布:2020-10-15 15:59
- 更新:2020-11-17 09:53
- 阅读:2266
产品分类: uniapp/App
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: MAC 10.15.6
HBuilderX类型: 正式
HBuilderX版本号: 2.9.3
手机系统: 全部
手机厂商: 苹果
页面类型: vue
打包方式: 离线
项目创建方式: HBuilderX
测试过的手机:
示例代码:
template:
<template>
<view class="view view-border-top-default">
<view class="view-body">
<web-view
class="webview"
@onPostMessage="handPostMessage"
:style="{ bottom: bottom }"
:webview-styles="webviewStyles"
style="width: 100%;"
:src="webviewURL"
></web-view>
</view>
</view>
</template>
script:
onLoad(option) {
// console.log('@option:', option)
if (option.title) {
uni.setNavigationBarTitle({
title: decodeURIComponent(option.title)
});
}
if (option.url) {
let userAgent = plus.navigator.getUserAgent()
userAgent = userAgent+' anjuleye/10.0'
if(option.modifyUserAgent){
userAgent = userAgent.replace('uni-app', 'uniapp')
}
plus.navigator.setUserAgent(userAgent)
this.webviewURL = 'https://mp.weixin.qq.com/s?__biz=MzI4NzE4ODgwOA==&mid=504688560&idx=1&sn=98c9c64832d40e7bb8d8db2efa94e2da&chksm=70313d974746b481a776554ca684423672c66690375c3696a9104a15972f9ea841c8396fba42#rd'
this.wvTimer = setTimeout(() => {
const currentWebview = this.$scope.$getAppWebview();
this.wv = currentWebview && currentWebview.children()[0];
this.wvTimer = null
}, 1000);
}
if (uni.getSystemInfoSync().platform === 'android') {
uni.onKeyboardHeightChange(res => {
console.log('onKeyboardHeightChange', res.height);
this.bottom = res.height;
});
}
},
template:
<template>
<view class="view view-border-top-default">
<view class="view-body">
<web-view
class="webview"
@onPostMessage="handPostMessage"
:style="{ bottom: bottom }"
:webview-styles="webviewStyles"
style="width: 100%;"
:src="webviewURL"
></web-view>
</view>
</view>
</template>
script:
onLoad(option) {
// console.log('@option:', option)
if (option.title) {
uni.setNavigationBarTitle({
title: decodeURIComponent(option.title)
});
}
if (option.url) {
let userAgent = plus.navigator.getUserAgent()
userAgent = userAgent+' anjuleye/10.0'
if(option.modifyUserAgent){
userAgent = userAgent.replace('uni-app', 'uniapp')
}
plus.navigator.setUserAgent(userAgent)
this.webviewURL = 'https://mp.weixin.qq.com/s?__biz=MzI4NzE4ODgwOA==&mid=504688560&idx=1&sn=98c9c64832d40e7bb8d8db2efa94e2da&chksm=70313d974746b481a776554ca684423672c66690375c3696a9104a15972f9ea841c8396fba42#rd'
this.wvTimer = setTimeout(() => {
const currentWebview = this.$scope.$getAppWebview();
this.wv = currentWebview && currentWebview.children()[0];
this.wvTimer = null
}, 1000);
}
if (uni.getSystemInfoSync().platform === 'android') {
uni.onKeyboardHeightChange(res => {
console.log('onKeyboardHeightChange', res.height);
this.bottom = res.height;
});
}
},
操作步骤:
打开无title的网页url
打开无title的网页url
预期结果:
导航栏可以返回
导航栏可以返回
实际结果:
导航栏返回键消失
导航栏返回键消失
bug描述:
报bug
代码见附件
示例网址
https://mp.weixin.qq.com/s?__biz=MzI4NzE4ODgwOA==&mid=504688560&idx=1&sn=98c9c64832d40e7bb8d8db2efa94e2da&chksm=70313d974746b481a776554ca684423672c66690375c3696a9104a15972f9ea841c8396fba42#rd
uniapp里的webview加载无title的网页时,导航栏返回键 会消失