javascript - requirejs如何做判断:是否加载一个模块或第三方库?
阿神
阿神 2017-04-10 14:41:00
0
2
529

不是按需加载。
是按条件加载,是这样的。页面上有这个:

<!--[if lt IE 9]>
    <script src="@ResHelper.Res("common/js/jquery.placeholder.js")"></script>
<![endif]-->

因为placeholder有用到jquery,而jquery是requirejs的依赖那里加载的,placeholder先于jquery加载了。

要怎么写?根据浏览器判断,符合的话,才添加placeholder依赖。

阿神
阿神

闭关修行中......

reply all(2)
大家讲道理

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
      });
   }
});
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template