RequireJS填补了前端模块化开发的空缺,RequireJS遵循AMD(异步模块定义,Asynchronous Module Definition)规范,越来越多的框架支持AMD,像最近的jQuery,但有一些也不支持,像Backbone,那如何在RequireJS使用Backbone呢?需要使用RequireJS设置它们的一些特性:如下

require.config({
    paths:{
        jquery : 'jquery-1.7.2',
        underscore : 'underscore',
        backbone : 'backbone',
        localstorage:'backbone-localstorage'
    },
    shim : {
        backbone : {
            deps : ['underscore'],
            exports : 'Backbone'
        },
        localstorage:{
            deps : ['backbone'],
            exports : 'Store'
        }
    }
});
require(['jquery', 'underscore', 'backbone'], function($, _, Backbone) {
    
});

 

相关文章:

  • 2021-07-07
  • 2021-09-12
  • 2022-01-05
  • 2021-07-10
  • 2022-12-23
  • 2021-07-08
猜你喜欢
  • 2021-08-24
  • 2022-03-07
  • 2021-08-25
  • 2022-12-23
  • 2021-12-18
  • 2021-05-24
  • 2022-12-23
相关资源
相似解决方案