Ember.js 简单余烬路由-如何定义多个路由?

Ember.js 简单余烬路由-如何定义多个路由?,ember.js,Ember.js,好了,伙计们,这真的不应该变得比这更简单。我定义了一个名为about的路由,并在模板中添加了一个指向about的链接,然后在outlet中运行该路由,余烬工作正常 然后,我添加了另一个名为foobars的路由,对其执行了相同的操作,并得到了一个未捕获的错误: Uncaught Error: assertion failed: The attempt to linkTo route 'foobars' failed. The router did not find 'foobars' in its

好了,伙计们,这真的不应该变得比这更简单。我定义了一个名为about的路由,并在模板中添加了一个指向about的链接,然后在outlet中运行该路由,余烬工作正常

然后,我添加了另一个名为foobars的路由,对其执行了相同的操作,并得到了一个未捕获的错误:

Uncaught Error: assertion failed: The attempt to linkTo route 'foobars' failed. The router did not find 'foobars' in its possible routes: 'about', 'index' 
这是我的余烬

App=Ember.Application.create

App.Router.map(function(){
    this.resource('about');
    this.resource('foobars');
});
我的简单html

<body>
<h1>ember</h1>

<script type="text/x-handlebars">
  <h2>application template</h2>
  <a>{{#linkTo 'about'}} about {{/linkTo}}</a>
  <a>{{#linkTo 'foobars'}} foobars {{/linkTo}}</a>
  {{ outlet }}
</script>

<script type="text/x-handlebars" id="about">
  <h2>about template</h2>
</script>

<script type="text/x-handlebars" id="foobars">
  <h2>foobars template</h2>
</script>

我希望定义两条路线与定义一条路线不会有太大的不同,但我似乎并不理解什么。有人能指出我理解上的错误吗?谢谢

您需要在以下表格中定义路由:

App.FoobarsRoute = Ember.Route.extend({
    model: function() {
        return App.Foobars.find();
    }
});

这通常会放在它自己的文件中:/routes/foobars\u route.js

我想你只是在重新加载页面之前没有保存文件。我试过你的例子,效果很好

但是,当我注释掉foobars路线时:

我在控制台中得到了相同的错误:

Error: assertion failed: The attempt to linkTo route 'foobars' failed. The router did not find 'foobars' in its possible routes: 'about', 'index'

特定错误与路由处理程序无关。它只是抱怨找不到名为foobars的路由。好吧,是的,这是类似的-我实际上有两个文件在运行,我正在编辑的一个文件在根目录中…不知怎么的。谢谢
App = Ember.Application.create();

App.Router.map(function() {
  this.resource("about");
  //this.resource("foobars");
});
Error: assertion failed: The attempt to linkTo route 'foobars' failed. The router did not find 'foobars' in its possible routes: 'about', 'index'