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

判断是否在微信, 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)
}
判断

你可能感兴趣的:(【常用公共方法】移动端常用(一))