0

我是 require.js 的新手。我将 html5shiv 用于 IE polyfill,它只在 IE 中执行。

现在,如何在 require.config 中定义 IE 特定条件?

require.config({
  paths: {
    jquery: 'libs/jquery',
    html5shiv : 'libs/html5shiv'
  }
});

html5shiv 应该只在 IE 中加载

4

2 回答 2

1

HTML5shiv 代码需要在 中发生,<head>如果您使用其他方式加载html5shiv.js其内置 shim 代码,则不会及时调用。

于 2014-01-03T12:37:20.497 回答
0

也许迟到了,但你可以使用已经准备好的Bowser

require(['bowser'],function(bowser){
    if (bowser.msie && bowser.version < 9) {
        //include your html5shiv/shim/modernizr here
    }
});

祝你好运!

于 2014-06-27T10:22:57.080 回答