【问题标题】:ember "Uncaught Error: Could not find module handlebars"ember“未捕获的错误:找不到模块把手”
【发布时间】:2014-12-25 05:00:52
【问题描述】:
Uncaught Error: Could not find module handlebarsember.prod.js:35

我在 ember 1.9.1 和 handlebars.runtime 2.0.0 中使用 requirejs。

我的垫片:

shim : {
    ember: {
        deps: [
            'jquery',
            'handlebars'
        ],
        exports: 'Ember'
    },
    handlebars: {
        exports: 'Handlebars'
    }....

我不断收到此错误:

未捕获的错误:找不到模块把手

1.9.1 与车把 2.0.0 兼容吗?当我回滚到 1.3.x 时,错误消失了。

您知道 2.0.0 有什么问题吗?解决方法是什么?

【问题讨论】:

标签: ember.js


【解决方案1】:

Handlebars 2.0.0 不会公开 Ember 期望存在的全局 window.Handlebars 变量。我正在做这样的事情来补偿:

define(['handlebars'], function (Handlebars) {
  window.Handlebars = Handlebars;

  require(['ember'], function () {
    // ...
  });
});

【讨论】:

  • 你把这段代码放在哪里?我尝试将它添加到我的 main.js,但我收到错误“不匹配的匿名定义()模块:函数(Handlebars)”
  • 我将它直接放入我的 RequireJS 清单中,在 requirejs.config() 之后。如果你有一个 main.js 来设置你的应用程序和东西,你可能想要更改我的代码,以便在 ... 所在的位置添加一个 require(['main'])。此外,这可能有助于解决您的错误:requirejs.org/docs/errors.html
猜你喜欢
  • 1970-01-01
  • 2017-01-28
  • 1970-01-01
  • 2021-11-24
  • 2015-11-22
  • 2018-12-01
  • 1970-01-01
  • 2022-10-25
  • 2022-08-13
相关资源
最近更新 更多