我试图找出让 enquire.js 在旧版浏览器(即 6-9)上工作的最佳方法。在 enquire 的网站上,它说使用modernizr 检查matchMedia 支持,如果不支持则加载polyfill。
Modernizr.load([
//first test need for polyfill
{
test: window.matchMedia,
nope: "/path/to/polyfill.js"
},
//and then load enquire
"/path/to/enquire.js"
]);
查看它建议的 polyfill,它说modernizr 已经将它包含在 Modernizr.mq() 中。
Used in:
Respond.js
FormFactor
Modernizr
https://github.com/paulirish/matchMedia.js/
我已经对此进行了调查,但找不到使这项工作正常进行的方法。