在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML/ html頁(yè)面訪問(wèn)后臺(tái)數(shù)據(jù)訪問(wèn)不到

html頁(yè)面訪問(wèn)后臺(tái)數(shù)據(jù)訪問(wèn)不到

<% for(var i = 0; i < dataList.length; i++) { %>

  <tbody>
    <tr data-id="<%=dataList[i].attributes.id%>">
          <th scope="row">
              <input type="checkbox" id="<%=dataList[i].attributes['id']%>">
          </th>
          <td><%=dataList[i].attributes["local"]%></td>
          <td></td>
    </tr>
  </tbody>
<% } %>



報(bào)錯(cuò):Uncaught TypeError: Cannot read property 'id' of undefined
at eval (eval at _.template (underscore.js:1442), <anonymous>:8:31)
at template (underscore.js:1449)
at s.initSetup (setupTopoManage.replaceNode.view.js?1510834444737:31)
at s.onClickSearchOriginNode 
回答
編輯回答
挽青絲

數(shù)據(jù)請(qǐng)求不到,接口返回是啥?dataList打印一下嘛,看看里面具體是啥
我underscore不太熟
你試試這樣行不行。

var templateTable2 = '<% _.each(dataList, function(n){ %>\
                      <tbody><tr data-id="<%=n.id %>">\
                              <th scope="row">\
                                <input type="checkbox" id="<%=n.id %>"</th>\
                                <td><%=n.local %></td>\
                                <td><%=n.upper %></td>\
                                </tr></tbody><% });%>';
 var data= [{ id: 101,
              local:'聯(lián)通',
              upper:'北京教育網(wǎng)' 
            }, {
              id: 102,
              local:'電信',
              upper:'北京教育網(wǎng)' 
           }];
 var tpl = _.template(templateTable2)({ dataList:data });
 console.log(tpl);
2017年1月29日 14:37