notitle_webview.vue
1.9 KB
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
<template>
<view>
<web-view :src="url"></web-view>
</view>
</template>
<script>
import { default as app_config } from '@/utils/app.js';
import common from '@/utils/common.js'
var wv;//计划创建的webview
export default {
data() {
return {
app_config,
url: '',
}
},
methods: {
},
onLoad(val) {
let data = JSON.parse(decodeURIComponent(val.info))
this.url = data.url
if (data.title) {
uni.setNavigationBarTitle({
title: data.title
})
}
},
onReady() {
let appInfo = app_config.app_info;
let header = {
AppVersion: encodeURI(JSON.stringify(appInfo))
}
// #ifdef APP-PLUS
var nwating = plus.nativeUI.showWaiting();
wv = plus.webview.create("", "normal_h5-webview", {
additionalHttpHeaders: {
header: header,
},
plusrequire: "none", //禁止远程网页使用plus的API,有些使用mui制作的网页可能会监听plus.key,造成关闭页面混乱,可以通过这种方式禁止
'uni-app': 'none', //不加载uni-app渲染层框架,避免样式冲突
top: common.customBarH,
height: uni.getSystemInfoSync().windowHeight
})
let pages = getCurrentPages()
let currentPage = pages[pages.length - 1]
var currentWebview = currentPage.$getAppWebview() //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效
currentWebview.append(wv);
console.log(header)
wv.loadURL(this.url, header);
wv.addEventListener('loaded', function () {
// wv.evalJS("$(\".header\").hide();");
nwating.close();
wv.show();
}, false);
// #endif
}
}
</script>
<style>
</style>