<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>
效果截图: