0

考虑我有以下 HTML 片段:

<div class="content" data-section-content></div>

我想用这样的 Ember 视图替换它:

App.ContentView = Ember.View.extend({
   tagName :"div",
   classNames : ["content"],
   ... ( how can i add the >> data-section-content << to the view )
});

将数据部分内容添加到视图的最佳方法是什么?

4

1 回答 1

0

似乎 <div class="content" data-section-content></div>是一样的<div class="content" data-section-content=""></div>

所以我可以通过实施来解决问题:

App.ContentView = Ember.View.extend({
   tagName :"div",
   classNames : ["content"],
   attributeBindings : ["data-section-content"],
   "data-section-content": ""
});

或更短

App.ContentView = Ember.View.extend({
   tagName :"div data-section-content",
   classNames : ["content"]
});
于 2013-04-12T21:21:03.503 回答