Skip to content
On this page

检查设备类型

使用navigator.userAgent 判断是移动设备还是电脑设备:

js
const judgeDeviceType =
      () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|OperaMini/i.test(navigator.userAgent) ? 'Mobile' : 'PC';

judgeDeviceType()  // PC | Mobile

Released under the MIT License.