关于余烬资源和路由的困惑

Confusion About Ember Resource vs Routes

本文关键字:路由 于余烬 资源      更新时间:2023-09-26

我一直在阅读Ember CLI 101以理解资源/路由的区别,但我很难理解下面的情况:

我用ember-cli创建了一个新项目,并运行:

ember g resource testme --pod

ember g route testme/testresource --pod .

然后,我添加了改变testme/template.hbs,看起来像:

This is test me1.
{{outlet}}

并将testme/testresource/template.hbs更改为

This is the test resource .
{{outlet}}

路由看起来像

  this.resource('testme', function() {
    this.resource('testresource', function() {});
  });

为什么导航到

http://localhost: 4200/testme testresource

礼物就

This is test me1. 

而非

This is test me1. This is the test resource .

如果我将testresource更改为route,我将得到两个句子。如果testresourceresource,为什么我不能得到两个?如果第二个模板没有被渲染,那还有什么意义呢?

作为参考,我的依赖项看起来像:

"jquery": "^1.11.1",
"ember": "1.10.0",
"ember-data": "1.0.0-beta.15",

资源有自己的命名空间,资源下的路由在资源下的命名空间

当Ember解析testresource模板时,它遵循此模式。如果它是路由器中的resource,它将查找名为testresource的模板。如果它是路由器中的route,它将查找resource/routetestme/testresource