所以基本上我从 WoW(魔兽世界)API 得到一个 JSON 响应:
this.url="http://eu.battle.net/api/wow/character/"+config.realm+"/"+config.charName+"fields=achievments&jsonp=?";
this.template = config.template.html();
$.when(this.fetch()).then(function(response){
console.log( response );
self.attachTemplate( response );
});
},
attachTemplate: function( data ){
var compTemplate = _.template( this.template, data );
console.log( compTemplate );
this.getContainer().append( compTemplate );
},
我的模板如下所示:
<h1><%=name%></h1>
<h5 style="color: black;"><strong style="color: black;"><%= class %></strong>
我越来越
Uncaught SyntaxError: Unexpected reserved word
显然我不能使用“类”这个词,因为它是一个 js 保留字。API 响应对象有一个名为 class 的字段。除了创建中间变量之外,还有其他解决方法吗?