uniapp

跳转外部域名网站

2020-03-10  本文已影响0人  荼蘼toome
<template>
    <web-view :webview-styles="{height: '100vh', width: '100vw'}" :src="src"></web-view>
</template>

<script>
    export default {
        data() {
            return {
                src: 'https://www.hjrqc.cn'
            }
        },
        onShow: function() {
            const src = plus.runtime.arguments || '';
            // 追加http路由         
            this.src = (src.match(/\/\/(https:\/\/.+)/) || [])[1] || this.src;
            console.log(this.src);
        }
    }
</script>

<style>
</style>
解决手机返回按钮的监听页面返回....
<template>
    <web-view :webview-styles="{height: '100vh', width: '100vw'}" :src="src"></web-view>
</template>

<script>
    export default {
        data() {
            return {
                src: 'https://www.hjrqc.cn'
            }
        },
        onShow: function() {
            const src = plus.runtime.arguments || '';
            this.src = (src.match(/\/\/(https:\/\/.+)/) || [])[1] || this.src;
            // 追加http路由
            console.log(this.src);
        },
        onBackPress(options) {
            const currentWebview = this.$mp.page.$getAppWebview();
            const wv = currentWebview.children()[0];

            wv.evalJS('history.back()')
            return true;
        } // 监听页面返回
        // onBackPress(options) {
        //  //右上角的
        //  console.log('    00',options)
        //  const currentWebview = this.$mp.page.$getAppWebview();
        //  if (currentWebview) {
        //      let child = currentWebview.children();
        //      for (let i = 0; i < child.length; i++) {
        //          currentWebview.remove(child[i]);
        //      }
        //  }
        //  return false;
        // }
    }
</script>

<style>
</style>
上一篇 下一篇

猜你喜欢

热点阅读