相关疑难解决方法(0)

我何时应该使用require()以及何时使用define()?

过去几天我一直在玩requirejs.我试图理解define和require之间的区别.

定义似乎允许模块分离并允许遵守依赖性排序.但它会下载所需的所有文件.虽然只需要在您需要时加载您需要的东西.

这两者可以一起使用,是否应该使用它们?

require requirejs

310
推荐指数
2
解决办法
9万
查看次数

要求使用shim配置的原因和时间

我从这里读apirequirejs文件

requirejs.config({
    shim: {
        'backbone': {
            //These script dependencies should be loaded before loading
            //backbone.js
            deps: ['underscore', 'jquery'],
            //Once loaded, use the global 'Backbone' as the
            //module value.
            exports: 'Backbone'
        },
        'underscore': {
            exports: '_'
        },
        'foo': {
            deps: ['bar'],
            exports: 'Foo',
            init: function (bar) {
                //Using a function allows you to call noConflict for
                //libraries that support it, and do other cleanup.
                //However, plugins for those libraries may still want
                //a global. "this" for the …
Run Code Online (Sandbox Code Playgroud)

javascript amd requirejs

96
推荐指数
2
解决办法
7万
查看次数

标签 统计

requirejs ×2

amd ×1

javascript ×1

require ×1