requirejs中的把手加载不成功

时间:2012-08-08 11:16:01

标签: javascript requirejs handlebars.js

paths: {
          jquery: 'libs/jquery/jquery-min',
          underscore: 'libs/underscore/underscore-min',
          backbone: 'libs/backbone/backbone-optamd3-min',
          handlebars: 'libs/handlebars/handlebars',
          text: 'libs/require/text'
      }

   define([
      'jquery',
       'underscore',
       'backbone',
       'collections/todos',
       'views/todos',
       'text!templates/stats.html',
       'common',
       'handlebars'
  ], function ($, _, Backbone, Todos, TodoView, statsTemplate, Common, handlebars) {
   //handlebars is null
   console.log("handlebars is",handlebars);

})

除了把手,其他人可以成功加载。为什么以及如何使handlbars成功加载。谢谢

1 个答案:

答案 0 :(得分:30)

首先,我可以看到您是新手,但请尝试在问题中添加更多详细信息,以帮助其他人为您提供帮助。

从源头上看,我不认为Handlebars与AMD兼容,因此you will need to shim it yourself。像这样:

requirejs.config({
    shim: {
        'handlebars': {
            exports: 'Handlebars'
        }
    }
});