Loading jQuery, Underscore and Backbone using RequireJS 2.0.1 and shim

后端 未结 3 1441
小蘑菇
小蘑菇 2021-01-30 00:55

I am experimenting a little bit with RequireJS 2.0.1. My goal is to load correctly jQuery, Underscore and Backbone. From the original RequireJS doc I d

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 01:58

    Can you actually avoid "shimming" jquery in the original example (where the path to jquery is set to 'libs/jquery'), since jquery adds the name "jquery" in their amd module definition?

    define( "jquery", [], function () { return jQuery; } );

    My experience is that you need to put jquery.js in the baseurl directory to get the jquery amd module defined as expected, or "shim" it like in the original example.

提交回复
热议问题