不是按需加载。 是按条件加载,是这样的。页面上有这个:
<!--[if lt IE 9]> <script src="@ResHelper.Res("common/js/jquery.placeholder.js")"></script> <![endif]-->
因为placeholder有用到jquery,而jquery是requirejs的依赖那里加载的,placeholder先于jquery加载了。
要怎么写?根据浏览器判断,符合的话,才添加placeholder依赖。
闭关修行中......
http://stackoverflow.com/questions/21097238/loading-ie-dependencies-with-requirejs
<!--[if lt IE 7]> <html class="ie lt-ie10 lt-ie9 lt-ie8 lt-ie7"> <![endif]--> <!--[if IE 7]> <html class="ie lt-ie10 lt-ie9 lt-ie8"> <![endif]--> <!--[if IE 8]> <html class="ie lt-ie10 lt-ie9"> <![endif]--> <!--[if IE 9]> <html class="ie lt-ie10><![endif]--> <!--[if !IE]><!--><html><!--<![endif]-->
require(['jquery'], function($) { // IE8 and below specific scripts if ($('html.lt-ie9').size()) { require(['/scripts/ie'], function(ieScript) { // ... do stuff }); } });
http://stackoverflow.com/questions/21097238/loading-ie-dependencies-with-requirejs