0

わかりましたみんな-これよりも簡単になるべきではありません。about という名前のルートを定義し、テンプレートに linkTo about を追加し、アウトレットを介して実行すると、ember は期待どおりに動作します。

次に、foobars という別のルートを追加し、それで同じことを行ったところ、キャッチされないエラーが発生しました。

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

これが私の燃えさしです

アプリ = 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>

私が言ったように、それはaboutテンプレートで動作するので、私の設定は大丈夫です. 次のように、それらを個別に追加することも試みました。

App.Router.map(function(){
    this.resource('about');
});

App.Router.map(function(){
    this.resource('foobars');
});

2 つのルートを定義することは、1 つのルートを定義することとそれほど変わらないと思いますが、何かを理解していないようです。誰かが私の理解の誤りを指摘できますか? ありがとう!

4

2 に答える 2