Backbone.js 使用RequireJS将Mustache加载为AMD模块-未定义Mustache

Backbone.js 使用RequireJS将Mustache加载为AMD模块-未定义Mustache,backbone.js,requirejs,typescript,mustache,Backbone.js,Requirejs,Typescript,Mustache,我在加载mustache.js作为带有RequireJS(用于主干模型)的AMD模块时遇到问题。我也开始使用TypeScript,因此我没有完全遵循依赖项和声明流 从app.ts开始: require.config({ paths: {'jquery': 'lib/jquery-1.8.3.min', 'underscore': 'lib/underscore.min', 'backbone': 'lib/backbone.min', 'mustache': 'lib/mustache'

我在加载mustache.js作为带有RequireJS(用于主干模型)的AMD模块时遇到问题。我也开始使用TypeScript,因此我没有完全遵循依赖项和声明流

从app.ts开始:

require.config({
    paths: {'jquery': 'lib/jquery-1.8.3.min', 'underscore': 'lib/underscore.min', 'backbone': 'lib/backbone.min', 'mustache': 'lib/mustache', 'appmain': 'AppMain'}, 
    shim: {mustache: { deps: ["jquery"] }, backbone: { deps: ["underscore", "jquery"] }, appmain: {deps: ["backbone", "mustache"] } } });

require(['appmain'], (main) => {
    var appMain = new main.AppMain();
    appMain.run();
});
appmain.ts:

import tm = module("models/TestModel");

export class AppMain {
    public run() {
        var testModel = new tm.TestModel()
    }
}
TestModel.ts:

/// <reference path="../modules/backbone.d.ts"/>
export class TestModel extends Backbone.Model {
    constructor(options?) {
        super(options);
    };
    initialize() {
        var stringTemplate = "{{something}}";
        Mustache.compile(stringTemplate);
    };
}
//
导出类TestModel扩展了主干{
构造函数(选项?){
超级(期权);
};
初始化(){
var stringTemplate=“{something}}”;
编译(stringTemplate);
};
}
虽然Mustache.js确实在TestModel.js之前加载,但我收到一个javascript错误,说“Mustache未定义”。我只是在这里使用mustache.js:所以我想我可能不明白AMD模块是如何正确声明的


我看到这个项目中有一些“AMD包装器”,但我似乎也不知道它们是如何使用的。

我不太了解TypeScript,但文档中提到编译器选项会将生成的javascript从CommonJS更改为AMD。(
--模块amd


希望这能帮上忙,因为小胡子确实有用,所以不需要加垫片。我不知道TypeScript以及它是如何与RequireJS集成的,但请尝试从配置的垫片阵列中删除小胡子

你的小胡子需要导出一些东西,所以小胡子不依赖于jQuery