美文网首页
【常用公共方法】移动端常用(一)

【常用公共方法】移动端常用(一)

作者: 北极星丶超帅的 | 来源:发表于2019-05-29 16:31 被阅读0次
    判断是否在微信, http://www.xajianzhan.com/show/54.html
    export const isWechat = /(micromessenger|webbrowser)/.test(navigator.userAgent.toLocaleLowerCase())
    
    判断是否手机端
    export const isPhone = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
    
    
    存储当前历史记录点,实现控制手机物理返回键的按钮事件
    export const pushHistory = () => {
      let state = {
        title: '',
        url: ''
      }
      window.history.pushState(state, state.title, state.url)
    }
    
    判断
    
    

    相关文章

      网友评论

          本文标题:【常用公共方法】移动端常用(一)

          本文链接:https://www.haomeiwen.com/subject/raiytctx.html