Ember - 预加载页面不会触发慢速模型

Ember - Preload page Not triggering for slow model

我正在尝试为我的慢速模型页面添加一个预加载页面。但是我的路由器不显示预加载模板。

这是我的路线结构:

http://localhost:4302/cs2i/purchase/purchaseDetails

this.route('cs2i', function() {

    this.route('purchase', function() {
      this.route('purchaseDetails', function(){
        this.route('loading'); //not loading I do have template
      });
      this.route('purchaseDetails-loading'); //not loading I do have template
    });
  });

这是什么问题?在呈现我的数据和模板之前,如何将预加载器放入我的路线?

提前致谢。

我的 'purchase' 页面也有一个动作,它甚至在数据加载之前就被触发了。

actions: {

        loading : function( transition, originRoute ){

            console.log("loding done");//getting before data load

        },

在您的路线上定义加载操作会覆盖默认行为(显示模板)。如果您想显示加载模板,您需要从加载操作中 return true

参见:https://guides.emberjs.com/v2.16.0/routing/loading-and-error-substates/#toc_the-code-loading-code-event

另请注意,如果您在 purchase 路由的模型挂钩中加载数据,将加载 purchase.loading template/route 而不是 purchase.purchaseDetails.loading,如您的描述路由器配置。