I want to add a wrapper class to the first div element in my page. I used to do this with a view. So, it seems that Ember 2.0 won't support Views anymore. So how can I do that now?
view/application.js:
import Ember from 'ember';
export default Ember.View.extend({
classNames: ['wrapper'],
});
Resulting in the following page:
<body class="ember-application">
<div id="ember573" class="ember-view wrapper">
the rest of my page in this div
</div>
</body>
How is this done now that views are deprecated?
答案 0 :(得分:7)
I used css to solve this problem:
body > .ember-view {
padding-left: 240px; //styles for container goes here
}
答案 1 :(得分:6)
我没有一个简洁的解决方案,但是从Ember.Component
内部对applications/view.js
进行子类化工作。
答案 2 :(得分:1)
Views
。从现在开始做事的方法是使用component
和route
。您可以通过执行以下操作来指定应用于组件的类名称:
export default Ember.Component.extend({
/* Wrap your component in primary class*/
classNames: ['primary'],
/*defined class binding*/
classNameBindings: ['isUrgent'],
isUrgent: true
});
有关如何自定义component
的所有信息都可以在ember文档中找到(click here to find out more)
答案 3 :(得分:0)
您现在不应该使用Views
,因为它们已被弃用。改为使用组件,例如:
import Ember from 'ember';
export default Ember.Component.extend({
classNameBindings: ['functionName'],
functionName: Ember.computed(function() {
// function logic
})
});