Backbone 응용 프로그램에서 밑줄을 사용할 때 문제가 있습니다. 콘솔에서 나는
캐치되지 않는 구문 에러 : 예기치 않은 토큰 ')'
그리고 그것은 저를 밑줄 라이브러리로 참조합니다.
underscore.js : 1443 행
내가하고 싶은 것은 ID로 템플릿을 선택하는 것입니다.
var UserList = Backbone.View.extend({
el: '.page',
render: function(){
var self = this;
var users = new Users();
users.fetch({
success:function(users){
console.log(users);
var template = _.template($('#user_list_template').html(), users);
self.$el.html(template);
}
});
}
});
다음은 내 스크립트 템플릿입니다.
<script type="text/template" id="user_list_template">
<table class="table striped">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<% _.each(users,function(user)){ %>
<tr>
<td><%= user.name %></td>
<td><%= user.age %></td>
</tr>
<% }); %>
</tbody>
</table>
</script>
그리고 내가 찾은 것처럼 문제는 다음 줄에 있습니다.
var template = _.template($('#user_list_template').html(), users);
문제가 무엇인지 제발 도와 주시겠습니까?
<% _.each(users,function(user)){ %>
이 줄에는 템플릿 )
앞에 추가 {
가 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다