Using non-AMD compatible javascript module with require.js?

后端 未结 3 914
鱼传尺愫
鱼传尺愫 2020-12-24 14:58

I\'m using require.js to help organize my Backbone.js based application.

I\'m trying to figure out the right way to use a 3rd party javascript library that is not AM

3条回答
  •  既然无缘
    2020-12-24 15:36

    The following should work with RequireJS 2.1.0+ assuming you've set up the paths correctly.

    require.config({
      shim: {
        'underscore': {
          exports: '_'
        },
        'backbone': {
          deps: ['underscore','jquery'],
          exports: 'Backbone'
        },
        'backbone-tastypie': {
          deps: ['backbone']
        }
      }
    );
    

提交回复
热议问题