我想补充一下
var mql = window.matchMedia("(max-width: 480px)"), window.matchMedia("(max-height: 479px)");到我现有的脚本中,这个脚本现在只有
var mql = window.matchMedia("(max-width: 480px)"). 当我添加第二个.matchMedia时,脚本根本不启动。
我应该添加多个mql吗?
下面是添加max-height之前的脚本:
发布于 2015-08-13 15:53:30
那不是有效的Javascript把它分配给两个不同的变量。
或者最好把媒体结合起来。
var mql = window.matchMedia("(max-width: 480px) and (max-height: 479px)");发布于 2015-08-13 16:00:01
看起来,您试图在一个变量中存储多个值。你考虑过用数组来做这件事吗?
var mqls = [
window.matchMedia("(max-width: 8480px)"),
window.matchMedia("(max-height: 497px)")
]然后,您应该能够遍历数组以获得您想要的效果。
有关更多信息,您可以尝试签出这个资源。。
祝好运!
https://stackoverflow.com/questions/31992964
复制相似问题