vue 移动端下载中转页

2018-11-13  本文已影响0人  夜息白鸽

安卓用户访问走安卓链接
ios用户访问走ios链接
简单写个笔记 下次直接复制粘贴

<template>
  <div id="app">
    <div class="logo">
      <img src="./assets/logo@2x.png" >
    </div>
    <div class="down_info">
      <p>{{version}}</p>
      <button type="button" name="button" class="down_bnt" @click.stop="downApp">下载</button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'App',
  data () {
    return {
      version: '项目名称 for Android',
      iosLink: 'https://*************************&platform=ios',
      androidLink: 'https://*************************&platform=android',
      downloadLink: ''
    }
  },
  created () {
    if (this.isIOS()) {
      this.downloadLink = this.iosLink
      this.version = '项目名称 for Ios'
    } else {
      this.downloadLink = this.androidLink
      this.version = '项目名称 for Android'
    }
    // window.location.href= this.downloadLink
  },
  methods: {
    isIOS () {
      var u = navigator.userAgent
      return !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
    },
    downApp () {
      window.location.href = this.downloadLink
    }
  }
}
</script>


上一篇下一篇

猜你喜欢

热点阅读