我有一些错误如下;
Uncaught ReferenceError: Marionette is not defined
我正在使用files(main.ts->config, app.ts-> first class of the app)
grunt watch (typescript compile with --module amd)使用以下内容。我的问题是指我的错误问题,如何导入 Marionette(modules/marionette.d.ts)
以便我可以使用Marionette.Application();
和配置我的应用程序?
主要.ts;
// Require JS all the things
/// <reference path="modules/require.d.ts" />
/// <reference path="modules/marionette.d.ts" />
require.config({
basePath: 'assets/js',
paths : {
backbone : 'vendor/backbone',
underscore : 'vendor/underscore',
jquery : 'vendor/jquery',
marionette : 'vendor/backbone.marionette',
debug : 'vendor/ba-debug',
handlebars: 'vendor/handlebars'
},
shim : {
jquery : {
exports : 'jQuery'
},
underscore : {
exports : '_'
},
backbone : {
deps : ['jquery', 'underscore'],
exports : 'Backbone'
},
marionette : {
deps : ['jquery', 'underscore', 'backbone'],
exports : 'Marionette'
},
handlebars: {
exports:'Handlebars'
},
debug: {
exports: 'debug'
}
}
});
// initalise the app
// load AMD module app.ts (compiled to app.js) , tsc --module AMD main.ts
// and include shims $, _, Backbone
require(['backbone', 'app','routers/router','routers/controller', 'debug', 'jquery','underscore'], (Backbone, App, CustomRouter, AppController, debug, $, _ ) => {
debug.log('starting app');
App.on('initialize:after', function(options) {
if (Backbone.history) {
Backbone.history.start();
}
});
var router = new CustomRouter({
controller : new AppController()
});
App.start();
});
应用程序.ts;
/// <reference path="modules/marionette.d.ts" />
var app:any = new Marionette.Application();
app.addRegions({
header : '#Header',
// main : CustomRegion.extend({el: '#main'})
main : '#Main'
});
app.addInitializer(function() {
});
谢谢