utils.js 491 Bytes
// utils/utils.js
export const deviceMixin = {
  computed: {
    $isMobile() {
      const userAgent = window.navigator.userAgent.toLowerCase();
      const mobileKeywords = ['android', 'iphone','windows phone'];

      for (const keyword of mobileKeywords) {
        if (userAgent.includes(keyword)) {
			// console.log(keyword);
          return true; // 如果包含移动设备关键词,则判断为移动端
        }
      }

      return false; // 否则判断为PC端
    }
  }
};