zoukankan      html  css  js  c++  java
  • Vue 实现微信提示浏览器转跳功能

    <template>
      <div class="main">
        <div :class="show==true ? 'block':'blocks'"></div>
      </div>
    </template>
    
    <script>
    import Vue from "vue";
    import { Popup } from "vant";
    import { Cell, CellGroup } from "vant";
    import { Dialog } from "vant";
    
    // 全局注册
    Vue.use(Dialog);
    Vue.use(Cell);
    Vue.use(CellGroup);
    Vue.use(Popup);
    export default {
      props: {
        msg: String
      },
      data() {
        return {
          imgUrl: "./live_weixin.png",
          codeValue: "http://192.168.32.214:8083/HymSon.apk",
          show: false
        };
      },
      mounted() {
        this.downApp();
      },
      methods: {
        downApp() {
          let ua = navigator.userAgent.toLowerCase();
    
          //Android终端
          let isAndroid = ua.indexOf("Android") > -1 || ua.indexOf("Adr") > -1; //Ios终端
          let isiOS = !!ua.match(/(i[^;]+;( U;)? CPU.+Mac OS X/);
          if (isWeixinBrowser()) {
            
            this.show = true;
            this.$router.push({
              path: "/product"
            });
          } else {
            if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
              //Ios
            } else if (/(Android)/i.test(navigator.userAgent)) {
              //Android终端
              window.console.log("这是安卓");
    
              window.location = this.codeValue;
            }
          }
    
          function isWeixinBrowser() {
            return /micromessenger/.test(ua) ? true : false;
          }
        }
      }
    };
    </script>
    
    <!-- Add "scoped" attribute to limit CSS to this component only -->
    <style >
    .block {
      width: 100%;
      height: 400px;
      background-color: gray;
      background-image: url("/live_weixin.png");//默认路劲为public下
      background-size: 100% 100%;
    }
    .blocks {
      width: 100%;
      height: 400px;
      background-color: gray;
      background-size: 100% 100%;
    }
    </style>

  • 相关阅读:
    暑假第二周总结
    7.18-7.24 第一周周报
    poj 3295 Tautology
    2016多校 #2 1006 Fantasia
    codeforces 698B Fix a Tree
    codeforces 699B Bomb
    HDU 4578(线段树
    CF 600F( 二分图
    hdu 5517 Triple(二维树状数组)
    HDU HDOJ5412(树套树or整体二分
  • 原文地址:https://www.cnblogs.com/zt199510/p/12692759.html
Copyright © 2011-2022 走看看