gpt4 book ai didi

javascript - Ember JS : Application loading route and template

转载 作者:行者123 更新时间:2023-12-03 12:11:52 25 4
gpt4 key购买 nike

当我的应用程序引导并开始使用ember-data从服务器加载数据时,我一直在尝试实现加载指示功能。创建了 templates/loading.hbs 模板。

到目前为止,加载模板在应用程序启动时尚未呈现,甚至尝试使用 {latency: 4000} 选项模拟网络延迟。

路由/application.js

export default Ember.Route.extend({
model: function() {
return this.store.find('items');
}
});

模板/loading.hbs

<div class="loading-overlay">
<div class="spinner"></div>
</div>

库版本

ember-cli 0.0.39
ember 1.6.1
handlebars 1.3.0
ember-data 1.0.0-beta.8

还要感谢 Balint Erdi,他有一篇关于使用 EmberJS 进行前端开发的精彩博客 http://balinterdi.com/2014/06/18/indicating-progress-loading-routes-in-ember-dot-js.html

解决方案

样本位于http://emberjs.com/guides/routing/loading-and-error-substates/真的很有帮助。

App.LoadingView = Ember.View.extend({
templateName: 'global-loading',
elementId: 'global-loading'
});

App.ApplicationRoute = Ember.Route.extend({
actions: {
loading: function() {
var view = this.container.lookup('view:loading').append();
this.router.one('didTransition', view, 'destroy');
}
}
});

谁能帮我解决这个问题吗?

最佳答案

您还需要一个 LoadingRoute ( Loading and error substates ) 或处理应用程序路由中的加载操作

关于javascript - Ember JS : Application loading route and template,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24928143/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com