vue中判断是iOS,安卓,以及微信的方法
16lz
2021-01-26
模板中: 其中,img是一张图片,在微信中提示打开浏览器下载
<div class="appwh" @click="download"><img src="../../static/images/app1.png" alt=""></div><div id="showad" v-show="ShowDark"><div class="pop"><img class="wxpic" src="../../static/images/liulan.png" alt=""></div></div>
data中:
data() {return {ShowDark: false}},
methods中:
download() {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.ShowDark = !this.ShowDark;this.$toast('我是微信');} else {if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {//iosthis.$toast('ios');window.location = 'http://www.baidu.com'} else if (/(Android)/i.test(navigator.userAgent)) {//androidthis.$toast('安卓');window.location = 'http://www.taobao.com'}}function isWeixinBrowser() {return (/micromessenger/.test(ua)) ? true : false;}},
style中:
// 蒙版遮罩层#showad {height: 100%;background: rgba(0, 0, 0, 0.7);background-size: 100% 100%;z-index: 999999;position: absolute;left: 0;right: 0;top: 0;}#showad .pop {position: absolute;left: 0;right: 0.6rem;margin: 0 auto;font-size: 0.35rem;top: 0.5rem;text-align: right;}#showad .pop .wxpic {width: 3.25rem;height: 2.66rem;}
更多相关文章
- Android(安卓)OKhttp请求遇到的问题
- Android连续点击两次返回键退出应用,提示“再按一次退出应用"
- win7 cmd终端连接android手机运行adb shell脚本命令
- ℃江让您从精通到入门:Android(安卓)Studio 简单实现ViewPager,可
- MAC NDK开发环境搭建
- eclipse中运行安卓程序,提示Failed to allocate memory: 8的解决
- Android培训班(4)
- android 显示消息框的方法
- Android(安卓)的提示接口-Toast