requireJS 中的车把加载不成功

handlebars in requirejs load not successfully

本文关键字:加载 不成功 requireJS      更新时间:2023-09-26
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);

})

除了车把,其他都可以成功加载。为什么以及如何使手柄杆成功加载。谢谢

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

从源头来看,我认为车把与AMD不兼容,因此您需要自己填充它。像这样:

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