一、定义
export const _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;
}
二、使用
if (_isMobile()) {
alert("手机端");
this.$router.push('/m_index');
} else {
alert("pc端");
this.$router.push('/pc_index');
}