需求:根据判断当前是PC端还是手机端,给页面显示不同的内容。

const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);

const title = ref("服务器错误");
const subTitle = ref("对不起,服务器出错了,请联系管理员");
if (!isMobile) {
  title.value = "客户端超时";
  subTitle.value = "请刷新页面进行重试";
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.