我是 require.js 的新手。我将 html5shiv 用于 IE polyfill,它只在 IE 中执行。
现在,如何在 require.config 中定义 IE 特定条件?
require.config({
paths: {
jquery: 'libs/jquery',
html5shiv : 'libs/html5shiv'
}
});
html5shiv 应该只在 IE 中加载
HTML5shiv 代码需要在 中发生,<head>
如果您使用其他方式加载html5shiv.js
其内置 shim 代码,则不会及时调用。
也许迟到了,但你可以使用已经准备好的Bowser
require(['bowser'],function(bowser){
if (bowser.msie && bowser.version < 9) {
//include your html5shiv/shim/modernizr here
}
});
祝你好运!