0

我在使用下划线模板在我的应用程序中创建backbone.js时运行以下代码,出现以下错误“意外标记<”。 这里是代码:下划线模板中的“意外标记<”

var data = [{'date':'03 Mar', 'users':5, 'not_ended_sessions':25}] 
var rowtemplate = _.template(this.template, {'data': data }); 
$(this.el).html(html); 

,这里是我的HTML模板:

<section class="clearfix"> 
    <table> 
     <thead class="title"> 
      <tr> 
       <th class='date'>Date</th> 
       <th>Users</th> 
       <th>Not Ended Session(s)</th> 
      </tr> 
     </thead> 
     <tbody> 
      <% _.each(data, function(el){ %> 
       <tr> 
        <td ><%= el.date %></td> 
        <td ><%= el.users %></td> 
        <td ><%= el.not_ended_sessions %</td> 
       </tr> 
      < % }); %> 
     </tbody> 
    </table> 
    <p class="Total Session(s)">0</p> 
</section> 

我已经看过了谷歌各种博客,并提出根据建议的变化,但仍然得到同样的错误。

有人可以看看它吗? 谢谢。

+0

我认为这是'<℅'而不是'<℅'....并且在最后的TD – dvenkatsagar

+0

另一个语法错误@dvenkatsagar,我已经尝试过了。但没有运气 –

+0

即使是最后的td:'<%= el.not_ended_sessions%>' – dvenkatsagar

回答

2

有一个在代码中的语法错误,最后TD

<section class="clearfix"> 
    <table> 
    <thead class="title"> 
     <tr> 
     <th class='date'>Date</th> 
     <th>Users</th> 
     <th>Not Ended Session(s)</th> 
     </tr> 
    </thead> 
    <tbody> 
    <% _.each(data, function(el){ %> 
     <tr> 
     <td ><%= el.date %></td> 
     <td ><%= el.users %></td> 
     <td ><%= el.not_ended_sessions %></td> 
     </tr> 
    <% }); %> 
    </tbody> 
    </table> 
    <p class="Total Session(s)">0</p> 
</section>