Backbone.js 带RequireJS和BackboneJS的手柄编译
requirejs配置:Backbone.js 带RequireJS和BackboneJS的手柄编译,backbone.js,requirejs,handlebars.js,Backbone.js,Requirejs,Handlebars.js,requirejs配置: require.config({ baseUrl: '/js/', paths: { jquery: './libs/jquery/jquery-1.10.1.min', underscore: './libs/underscore/underscore-min', backbone: './libs/backbone/backbone-min', handlebars: './libs/h
require.config({
baseUrl: '/js/',
paths: {
jquery: './libs/jquery/jquery-1.10.1.min',
underscore: './libs/underscore/underscore-min',
backbone: './libs/backbone/backbone-min',
handlebars: './libs/handlebars/handlebars',
templates: '/templates'
},
shim: {
underscore: {
exports: '_'
},
backbone: {
deps: ['jquery', 'underscore'],
exports: 'Backbone'
}
}
});
shim: {
handlebars: {
exports: 'Handlebars'
},
视图:
我遇到了以下错误:
Uncaught TypeError: Cannot call method 'compile' of undefined.
将此添加到您的垫片配置:
require.config({
baseUrl: '/js/',
paths: {
jquery: './libs/jquery/jquery-1.10.1.min',
underscore: './libs/underscore/underscore-min',
backbone: './libs/backbone/backbone-min',
handlebars: './libs/handlebars/handlebars',
templates: '/templates'
},
shim: {
underscore: {
exports: '_'
},
backbone: {
deps: ['jquery', 'underscore'],
exports: 'Backbone'
}
}
});
shim: {
handlebars: {
exports: 'Handlebars'
},
将此添加到您的垫片配置:
require.config({
baseUrl: '/js/',
paths: {
jquery: './libs/jquery/jquery-1.10.1.min',
underscore: './libs/underscore/underscore-min',
backbone: './libs/backbone/backbone-min',
handlebars: './libs/handlebars/handlebars',
templates: '/templates'
},
shim: {
underscore: {
exports: '_'
},
backbone: {
deps: ['jquery', 'underscore'],
exports: 'Backbone'
}
}
});
shim: {
handlebars: {
exports: 'Handlebars'
},
如何加载预编译模板?@chovy,我使用requirejs handelbarsplugin@chovy我想我用过这个——幸运的是,你加载预编译模板了吗?@chovy,我用的是requirejs handelbarsplugin@chovy我想我用过这个祝你好运