0
我正在尝试在j Query查询插件中使用Require JS和Handlebars,但我得到的只是“把手未定义”。把手正在正确加载。RequireJS和把手 - 把手未定义
我的配置:
require.config({
baseUrl: "static/js/lib",
paths: {
"jquery": "jquery-1.10.2.min",
"handlebars": "handlebars-v3.0.1",
},
shim: {
"jquery.myplugin": {
deps: ["handlebars"]
}
}
});
,并要求该插件:
require(["jquery"], function(){
if($('[data-init="myplugin"]').size() > 0){
require(["jquery.myplugin"], function(){
$(function(){
Handlebars.compile("<a></a>"); // This throws Handlebars is undefined
});
$('[data-init="myplugin"]').myplugin();
});
}
});
然后,我想用这个插件内把手。我如何将Handlebars传递给我的插件,以便我可以编译模板? (在脚本标记中)
test in console require('handlebars')。compile(“”)是对的吗? –