0

我有这样的数据:

{
   "error":false,
   "data":{
      "category":"default",
      "resultCount":3,
      "results":[
         {
            "id":"",
            "articleId":"_9773721056",
            "sourceCount":0,
            "groupId":1,
            "newsText":"Solution Partner Onboarding and Support Specialist",
            "source":"Tech Vibes",
            "dateText":"Sep 10, 20:00 PDT",
            "sourceAccessStatus":0,
            "docType":"",
            "commonArticles":[
            ]
         },
         {
            "id":"",
            "articleId":"_9732124200",
            "sourceCount":0,
            "groupId":0,
            "newsText":"HootSuite Partners with Nexgate to Improve Social Security",
            "source":"Big News Network",
            "dateText":"Sep 05, 12:07 PDT",
            "sourceAccessStatus":0,
            "docType":"",
            "commonArticles":[
            ]
         },
         {
            "id":"",
            "articleId":"_9685221995",
            "sourceCount":0,
            "groupId":2,
            "newsText":"SugarCRM Teams up with HootSuite",
            "source":"Destination CRM",
            "dateText":"Aug 30, 14:04 PDT",
            "sourceAccessStatus":0,
            "docType":"",
            "commonArticles":[
            ]
         }
      ],
      "agentId":29,
      "agentName":"Partnerships",
      "mode":"SellingTrigger"
   },
   "errorMessage":""
}

我这样写我的模板:

<div class="article-title">
    <a class="article article_tooltip" target="_blank"><%=newsText%></a>
</div>

但是在html中,结果只是显示:<%=newsText%>,而不是真实数据,我不知道为什么。希望得到您的帮助。谢谢你。

4

1 回答 1

0

Seems like you forgot to compile a template:

Backbone.View.extend({
  template: _.template('.. <%= newsText %> ..'),
  render: function () {
    this.$el.html(this.template(yourErrorJSON));
    return this;
  }
});
于 2013-10-17T15:24:01.360 回答