判断移动端或者PC端
2020-01-03 本文已影响0人
蜗牛和曼巴
created() {
const ua = navigator.userAgent
const ipad = ua.match(/(iPad).*OS\s([\d_]+)/)
const isIphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/)
const isAndroid = ua.match(/(Android)\s+([\d.]+)/)
const isMobile = isIphone || isAndroid
if (isMobile) {
location.href = 'http://'
} else {
location.href = 'http://'
}
}