在我的应用程序中,我决定使用把手,我正在使用 requirejs 并“填充”把手。但我不断收到错误消息:“SyntaxError: Expected an identifier but found '(' instead” - 我不知道我犯了什么错误..
要求:
requirejs.config({
baseUrl: 'js',
paths: {
"jquery" : 'lib/jquery-1.9.1.min',
"underscore": "lib/underscore-min",
"backbone" : "lib/backbone-min",
"handleBars": "lib/handlebars",
"routers" : "router/routers"
},
shim:{
"underscore":{
exports: '_'
},
"backbone":{
exports: 'Backbone',
deps:['underscore']
},
"handleBars":{
exports: 'Handlebars',
deps:['jquery', 'backbone']
}
}
});
require(["utils/utils","handleBars"],function (utils,handleBars) {
var x = handleBars.compile($("#navi-template").html());
console.log(x); //getting function
console.log(x.({"name":"new name"})); //getting error.
});
我的模板是:
<script id="navi-template" type="text/x-handlebars-template">
<div class="subNavi">
<ul>
<li class="active"><a class="dashboard" href="#/general/dashBoard/">{{name}}</a></li>
</ul>
</div>
</script>
任何人都弄清楚,这里发生了什么错误?