判断是否为移动端(横屏竖屏)

2019-04-15  本文已影响0人  叶叶叶xxx

这段代码可以显示用户浏览器是否为移动端

 !!navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)

返回值为布尔值

判断移动端横竖屏
orient () {
      if (window.orientation === 90 || window.orientation === -90) {
        console.log('横屏')
      } else if (window.orientation === 0 || window.orientation === 180) {
        console.log('竖屏')
      }
    }
上一篇 下一篇

猜你喜欢

热点阅读