Javascript 模板标记不工作下划线/主干

Javascript 模板标记不工作下划线/主干,javascript,jquery,backbone.js,underscore.js,Javascript,Jquery,Backbone.js,Underscore.js,我正在使用主干线和下划线来显示帖子列表。我创建了两个视图,一个用作帖子的容器,另一个用于显示帖子本身。我试图将模板标记用于下划线,但遇到了一个奇怪的问题。这些标签似乎不起作用 我已经按顺序加载了我的库,在html btw的顶部 关于我做错了什么有什么建议吗 以下是我的观点 var ListContainerView = SOCIView.extend({ el: $(".display_body") template: _.template($('#ListContainerView'

我正在使用主干线和下划线来显示帖子列表。我创建了两个视图,一个用作帖子的容器,另一个用于显示帖子本身。我试图将模板标记用于下划线,但遇到了一个奇怪的问题。这些标签似乎不起作用

我已经按顺序加载了我的库,在html btw的顶部

关于我做错了什么有什么建议吗

以下是我的观点

var ListContainerView = SOCIView.extend({
  el: $(".display_body")
  template: _.template($('#ListContainerView').html()),

  initialize: function () {
      _.bindAll(this, "render", "addAll");
      this.collection.bind("reset", this.render);
  },

  render: function(){
      $(this.el).html(this.template());
      this.addAll();
  },

  addAll: function () {
      this.collection.each(this.addOne);
  },

  addOne: function (model) {
      view = new ListItemView({ model: model });
      $("ul", this.el).append(view.render());
  }

});




var ListItemView = SOCIView.extend({ 
  tagName: "li",
  template: _.template($("#ListItemView").html()),

  initialize: function () {
      _.bindAll(this, 'render');
  },

  render: function () {
      return $(this.el).append(this.template(this.model.toJSON())) ;
  }

});
还有我的数据,如果需要

[
  {
    "id":"1",
    "schedule":"2020-0417 17:00:00",
    "utc_offset":"420",
    "project_id":"1",
    "network":"facebook",
    "network_name":"TestFacebookPage",
    "network_thumb":"https://scontent.xx.fbcdn.net/v/t1.0-9/17634406_1854330461448271_6787736791983791423_n.jpg?oh=e4c3a3573c0fc59359422cfd66a3865a&oe=598721E7","message":"Test Post 1 (just text, approved)",
    "data":[],
    "customer_approved":"1",
    "manager_approved":"1",
    "rejection_message":"",
    "created_at":"2020-0413 17:41:03",
    "created_by":"admin",
    "created_by_id":"1",
    "created_by_name":"John Admin"
},

{
    "id":"2",
    "schedule":"2020-0419 19:00:00",
    "project_id":"1",
    "network":"facebook",
    "network_name":"TestFacebookPage",
    "network_thumb":"https://scontent.xx.fbcdn.net/v/t1.0-9/17634406_1854330461448271_6787736791983791423_n.jpg?oh=e4c3a3573c0fc59359422cfd66a3865a&oe=598721E7",
    "message":"Test Post 2 (text with image, approved)  Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
    "data":{"pictures":["https://pbs.twimg.com/media/C9T6n0UUwAAOBaU.jpg"],"image_added":"true","picture":"https://pbs.twimg.com/media/C9T6n0UUwAAOBaU.jpg","type":"photo"},
    "customer_approved":"1",
    "manager_approved":"1",
    "rejection_message":"",
    "rejection_message_manager":"",
    "created_at":"2020-0413 17:42:34",
    "created_by":"admin",
    "created_by_id":"1",
    "created_by_name":"John Admin"
},

{
    "id":"3",
    "schedule":"2020-0421 22:00:00",
    "network":"facebook","network_name":
    "TestFacebookPage","network_thumb":"https://scontent.xx.fbcdn.net/v/t1.0-9/17634406_1854330461448271_6787736791983791423_n.jpg?oh=e4c3a3573c0fc59359422cfd66a3865a&oe=598721E7",
    "message":"Test Post 3 (link, approved) http://www.adultswim.com/videos/rick-and-morty/",
    "data":{"image_added":"true","pictures":["http://i.cdn.turner.com/adultswim/big/img/2015/07/17/Rick%26MortyS02_fbsearchTn.jpg"],"picture":"http://i.cdn.turner.com/adultswim/big/img/2015/07/17/Rick%26MortyS02_fbsearchTn.jpg","link":"http://www.adultswim.com/videos/rick-and-morty/","name":"Watch Rick and Morty on Adult Swim","caption":"www.adultswim.com","description":"Every episode of Rick and Morty is now on AdultSwim.com for free. Rick is a mad scientist who drags his grandson, Morty, on crazy sci-fi adventures. Their escapades often have potentially harmful consequences for their family and the rest of the world. Join Rick and Morty on AdultSwim.com as they trek through alternate dimensions, explore alien planets, and terrorize Jerry, Beth, and Summer.","domain":"www.adultswim.com","type":"link"},
    "customer_approved":"1",
    "manager_approved":"1",
    "rejection_message":"",
    "created_at":"2020-0413 17:43:29",
    "created_by":"admin",
    "created_by_id":"1",
    "created_by_name":"John Admin"
},

{
    "id":"4",
    "schedule":"2020-0424 17:00:00",
    "network":"facebook",
    "network_name":"TestFacebookPage",
    "network_thumb":"https://scontent.xx.fbcdn.net/v/t1.0-9/17634406_1854330461448271_6787736791983791423_n.jpg?oh=e4c3a3573c0fc59359422cfd66a3865a&oe=598721E7",
    "message":"Test Post 4 (text, pending)",
    "data":[],
    "customer_approved":"0",
    "manager_approved":"1",
    "rejection_message":"",
    "created_at":"2020-0413 17:43:48",
    "created_by":"admin",
    "created_by_id":"1",
    "created_by_name":"John Admin"
},

{
    "id":"5",
    "schedule":"2020-0426 19:00:00",
    "network":"facebook",
    "network_name":"TestFacebookPage",
    "network_thumb":"https://scontent.xx.fbcdn.net/v/t1.0-9/17634406_1854330461448271_6787736791983791423_n.jpg?oh=e4c3a3573c0fc59359422cfd66a3865a&oe=598721E7",
    "message":"Test Post 5 (picture, pending)",
    "data":[],
    "customer_approved":"0",
    "manager_approved":"1",
    "rejection_message":"",
    "created_at":"2020-0413 17:44:03",
    "created_by":"admin",
    "created_by_id":"1",
    "created_by_name":"John Admin"
},

{
    "id":"6",
    "schedule":"2020-0428 21:00:00",
    "network":"facebook",
    "network_name":"TestFacebookPage",
    "network_thumb":"https://scontent.xx.fbcdn.net/v/t1.0-9/17634406_1854330461448271_6787736791983791423_n.jpg?oh=e4c3a3573c0fc59359422cfd66a3865a&oe=598721E7",
    "message":"Test Post 6 (link, pending) https://www.reddit.com/",
    "data":{
        "image_added":"true",
        "pictures":["https://b.thumbs.redditmedia.com/2Hwaff37fC4f37j-3orrbjVAOVBChqbdm_dXeIhjlNw.jpg"],
        "picture":"https://b.thumbs.redditmedia.com/2Hwaff37fC4f37j-3orrbjVAOVBChqbdm_dXeIhjlNw.jpg",
        "link":"https://www.reddit.com/",
        "name":"reddit: the front page of the internet",
        "caption":"www.reddit.com",
        "description":"reddit: the front page of the internet",
        "domain":"www.reddit.com",
        "type":"link"
        },
    "customer_approved":"0",
    "manager_approved":"1",
    "rejection_message":"",
    "created_at":"2020-0413 17:44:19",
    "created_by":"admin",
    "created_by_id":"1",
    "created_by_name":"John Admin"
  }
]

以下内容中存在语法错误:
$(“.display_body:”.template($(“#ListContainerView”).html()
\uuz.bindAll
是无用的,您不必使用它,因为它已经是默认情况下正确传递上下文的对象。您在使用上下文时遇到问题,因为您没有使用上下文参数。上有一个答案列表,它处理您可能遇到的最常见的主干问题。
$(“ul”,this.el)
应该是
这个。$('ul')
$(this.el)
应该是
这个。$el
。.bindAll
现在很少需要,而且
listenTo
通常用来代替
bind
。您是否使用了旧教程?下面有语法错误:
$(.display>)“:\.template($('#ListContainerView').html())
\uuz.bindAll
是无用的,您不必使用它,因为它已经是默认情况下正确传递上下文的对象。您在使用上下文时遇到问题,因为您没有使用上下文参数。上有一个答案列表,它处理您可能遇到的最常见的主干问题。
$(“ul”,this.el)
应该是
这个。$('ul')
$(this.el)
应该是
这个。$el
。.bindAll
现在很少需要,而且
listenTo
通常被用来代替
bind
。你是不是在用以前的教程?