美文网首页uniapp
跳转外部域名网站

跳转外部域名网站

作者: 荼蘼toome | 来源:发表于2020-03-10 09:39 被阅读0次
<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>

相关文章

网友评论

    本文标题:跳转外部域名网站

    本文链接:https://www.haomeiwen.com/subject/rzpidhtx.html