mobile-detect

const Mobile_Detect = require('mobile-detect'),

class MobileDetect {
    getMobileModel(device_type) {
      // const device_type = window.navigator.userAgent;//获取userAgent信息  
      const md = new Mobile_Detect(device_type);//实例化mobile-detect  
      return md.phone()
    }

    getOs(device_type) {
        //  const device_type = window.navigator.userAgent;//获取userAgent信息  
        const md = new Mobile_Detect(device_type);//实例化mobile-detect  
        return md.os();
    }
  
    static getInstance() {
      if (!this.instance) {
        this.instance = new this()
      }
      return this.instance
    }
  }
  
  export default MobileDetect

https://www.npmjs.com/package/mobile-detect

你可能感兴趣的:(mobile-detect)