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>

  • 相关阅读:
    js 去除金额的千位分隔符
    vue中的iviewUI导出1W条列表数据每次只导出2000条的逻辑
    js取整数、取余数的方法
    http协议
    vue 项目安装sass的依赖包
    浅析vue的双向数据绑定
    闭包
    Top 20 NuGet packages for captcha
    IIS URL Rewrite Module的防盗链规则设置
    IIS URL Rewrite – Installation and Use
  • 原文地址:https://www.cnblogs.com/zt199510/p/12692759.html
Copyright © 2011-2022 走看看