📜  javascript 检查较小的窗口宽度 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:32.728000             🧑  作者: Mango

代码示例1
window.addEventListener("resize", function() {
  if (window.matchMedia("(min-width: 500px)").matches) {
    console.log("Screen width is at least 500px")
  } else {
    console.log("Screen less than 500px")
  }
})