我在点击这个链接进行路由跳转时需要判断是移动端还是pc端
<router-link @click.native="isMobile" to="/resume" tag="h2">简历</router-link>
methods: {
isMobile() {
console.log("1234321");
this.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
);
console.log(this.flag);
}
}
点击pc端按钮显示:
点击移动端按钮显示: