handlebars in requirejs load not successfully

你说的曾经没有我的故事 提交于 2019-12-07 11:11:03

问题


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);

})

Except handlebars,others can load successfully.Why and how to make handlbars load successfully.thanks


回答1:


Firstly, I can see that you're new but please try to add more detail to your question to help others help you.

From glancing at the source I don't think Handlebars is compatible with AMD, therefore you will need to shim it yourself. Something like this:

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


来源:https://stackoverflow.com/questions/11863351/handlebars-in-requirejs-load-not-successfully

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!