javascript requirejs 中的把手加载不成功
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11863351/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
handlebars in requirejs load not successfully
提问by shawnXiao
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);
})
})
Except handlebars,others can load successfully.Why and how to make handlbars load successfully.thanks
除了车把,其他都可以成功加载。为什么以及如何使车把加载成功。谢谢
回答by Simon Smith
Firstly, I can see that you're new but please try to add more detail to your question to help others help you.
首先,我可以看到您是新手,但请尝试在您的问题中添加更多细节以帮助其他人帮助您。
From glancing at the source I don't think Handlebars is compatible with AMD, therefore you will need to shim it yourself. Something like this:
从源头上看,我认为 Handlebars 与 AMD 不兼容,因此您需要自己填充它。像这样的东西:
requirejs.config({
shim: {
'handlebars': {
exports: 'Handlebars'
}
}
});