Javascript Ember.js-Pod结构中的错误状态

Javascript Ember.js-Pod结构中的错误状态,javascript,ember.js,ember-cli,Javascript,Ember.js,Ember Cli,这是我在innera pp/pods中的结构: |-application |-index |-error |-user ||-index ||-view ||-edit 发生错误时,ember不会加载错误路由。 相反,它尝试加载一个子路由,如index\u error或user\u error,但这些子路由不存在 如何在出现任何错误时强制Ember加载根错误路由 余烬v2.1 Ember Cli v1.13.8我成功地在pod结构中显示了错误路由,如下所示: -app --pods ----

这是我在inner
a pp/pods
中的结构:

|-application
|-index
|-error
|-user
||-index
||-view
||-edit
发生错误时,ember不会加载
错误
路由。 相反,它尝试加载一个子路由,如
index\u error
user\u error
,但这些子路由不存在

如何在出现任何错误时强制Ember加载根
错误
路由

余烬v2.1
Ember Cli v1.13.8

我成功地在pod结构中显示了错误路由,如下所示:

-app
--pods
----something
------template.hbs
------route.js
----error
------template.hbs
export default Ember.Route.extend({

  model() {
   throw new Error('AAA');
 }

});
-app
--pods
----something
------template.hbs
------route.js
------error
--------template.hbs
----error
------template.hbs
如果我在/route.js上抛出如下错误:

-app
--pods
----something
------template.hbs
------route.js
----error
------template.hbs
export default Ember.Route.extend({

  model() {
   throw new Error('AAA');
 }

});
-app
--pods
----something
------template.hbs
------route.js
------error
--------template.hbs
----error
------template.hbs
并具有
错误/模板.hbs
,内容如下:

Arrrh, errror!!!!
它显示错误消息

如果您想要
某个东西的错误子路由
,我想您需要以下内容:

-app
--pods
----something
------template.hbs
------route.js
----error
------template.hbs
export default Ember.Route.extend({

  model() {
   throw new Error('AAA');
 }

});
-app
--pods
----something
------template.hbs
------route.js
------error
--------template.hbs
----error
------template.hbs


根据上面的
app/application/error
是pod结构中的默认值。

您提供的结构实际上应该与您描述的内容完全一致

请看一个例子。单击“查看用户”将转换到
用户。查看
路线,但单击“编辑用户”将在
用户中引发异常。编辑
路线,而将您置于
错误
路线上

需要注意的一点是,不应该自己在
router.js
中添加错误路由。它接收转换错误作为其模型,因此如果您手动执行
this.route('error')
并且不给它一个动态段,转换将失败


如果您想更准确地控制在任何转换过程中发生错误时发生的情况,您可以在应用程序路由上实现
error
操作

actions: {
  error(thrownError) {
    this.transitionTo('my-error-route'); // Or whatever other handling you want
  }
}

您可以在中看到这种安排的完整示例。请注意,这与中的有细微的区别,因为它将产生一个完整的转换(即URL将被更新),而不仅仅是移动到一个子状态。

好吧,您的回答并没有解决我的应用程序中的问题,但您证明了这是应该的+50您能否提供一个关于子例程
某物
错误的旋转?我不能让它工作。