判断当前是否为PC端方法
2018-12-03 本文已影响0人
Fortune_Cookie
<script type="text/javascript">
function initView(){
var ua = navigator.userAgent.toLowerCase();
var mobile = /mobile/gi.test(ua);
isPC = !mobile;
if(isPC){
console.log('当前为PC')
}
else
{
console.log('当前不是PC')
}
}
initView();
</script>
效果截图:
Chrome设置为IPhone6
用电脑浏览器打开时