浏览器中点击按钮跳转到自家APP
- 普通浏览器
if (this.open) { return } // 防止多次点击 const ua = navigator.userAgent const isWeixinUA = ua.toLowerCase().indexOf('micromessenger') > -1 // 是否微信环境 const isAndroid = ua.indexOf('Android') > -1 || ua.indexOf('Adr') > -1 // android终端 const isIOS = !!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) // ios终端 if (isIOS) { window.location.href = 'itms-apps://itunes.apple.com/cn/app/appId' } else if (isWeixinUA) { this.showTips = true // 微信环境给个跳转到普通浏览器的提示 } else if (isAndroid) { this.open = true // 这里是APP的路由 window.location.href = 'xxx://app:8888/homePage' setTimeout(() => { // 3秒后没有跳转,则到下载页 this.open = false window.location.href = 'apk下载地址' }, 3000) } else { window.location.href = 'apk下载地址' }
- 微信浏览器:文档地址