vue移动端和手机端两端(vue-判断设备是手机端还是pc端)
export default { //App.vue mounted() { if (this._isMobile()) { alert("手机端"); this.$router.replace('/mob'); } else { alert("pc端"); this.$router.replace('/index.html'); } }, methods: { //App.vue _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; } } }
代码改变了我们,也改变了世界