vue 检测打开网页设备是移动端还是PC端

 methods: {
	isMobile() {
	      let flag = navigator.userAgent.match(
	        /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
	      );
	      return flag;
	    },
    },
    mounted() {
    if (this.isMobile()) {
      alert("手机端");
    } else {
      alert("pc端");
    }
  },

你可能感兴趣的:(vue.js,javascript,iphone)