notitle_webview.vue 1.9 KB
<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>