如何仅渲染嵌入式JavaScript桌面设备(宽度> 1024像素)
我必须搜索许多代码,但是不起作用
谢谢
我不太确定您是什么意思是呈现嵌入式JavaScript,但我假设您的意思是只想在宽度超过1024像素的设备上运行代码。
也许类似以下内容的工作:
if (window.innerWidth >= 1024) {
// Code to run on wide displays only
console.log("This will only happen if the window is wide enough");
}
https://developer.mozilla.org/en-US/docs/Web/API/window/innerWidth