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>

  • 相关阅读:
    Android使用SQLite数据库(2)
    Android使用SQLite数据库(1)
    使用Eclipse为Android定义style
    SharedPreferences写入和读出数据
    AlertDialog.Builder弹出对话框
    Android退出时关闭所有Activity的方法
    获取PC或移动设备的所有IP地址
    Android文件的分割和组装
    到底什么是跨域?附解决方案!
    超详细 Nginx 极简教程
  • 原文地址:https://www.cnblogs.com/zt199510/p/12692759.html
Copyright © 2011-2022 走看看