安卓用戶訪問(wèn)走安卓鏈接
ios用戶訪問(wèn)走ios鏈接
簡(jiǎn)單寫個(gè)筆記 下次直接復(fù)制粘貼
<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: '項(xiàng)目名稱 for Android',
iosLink: 'https://*************************&platform=ios',
androidLink: 'https://*************************&platform=android',
downloadLink: ''
}
},
created () {
if (this.isIOS()) {
this.downloadLink = this.iosLink
this.version = '項(xiàng)目名稱 for Ios'
} else {
this.downloadLink = this.androidLink
this.version = '項(xiàng)目名稱 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>