我正在更新到Ember 1.13,我想在我用来从View调用didInsertElement的应用程序模板的后台淡入淡出.
App.ApplicationView = Ember.View.extend({
didInsertElement: function() {
$('#login-bg').fadeIn(600);
}
});
Run Code Online (Sandbox Code Playgroud)
抛出一个已弃用的因为视图正在消失.Ember是否为模板创建了一个组件?这不起作用:
App.ApplicationComponent = Ember.Component.extend({
didInsertElement: function() {
$('#login-bg').fadeIn(600);
}
});
Run Code Online (Sandbox Code Playgroud)
到目前为止,还没有默认的应用程序组件在幕后工作,但您可以创建一个并将应用程序模板包装在其中,如下所示:
// app/templates/application.hbs
{{#application-area}}
{{outlet}}
{{/application-area}}
// app/templates/components/application-area.hbs
<div id="login-bg">
{{yield}}
</div>
// app/components/application-area.js
import Ember from 'ember';
export default Ember.Component.extend({
didInsertElement () {
Ember.$('#login-bg').fadeIn(600);
}
});
Run Code Online (Sandbox Code Playgroud)