当您/r/xxx
在浏览器中点击时,Ember 会查找与subreddit
. 首先它寻找'subreddit'
,然后寻找'subreddit/index'
. 如果 ' subreddit
' 如果找到,则将其渲染,然后如果'subreddit/index'
也找到,则将其渲染到{{outlet}}
of 中'subreddit'
。如果'subreddit'
没有找到,Ember 将继续前进'subreddit/index'
。还为嵌套在 下的'subreddit'
任何子路径呈现模板,/subreddit
例如. 有点像“每个模型布局”模板,它允许您包装(装饰)所有子路径模板。'link'
/r/xxx/yyy
'subreddit'
像这样的东西应该让您保留嵌套路由,并允许您使用 Ember 默认行为。
<script type="text/x-handlebars" data-template-name="subreddit">
<p>A static header bar for this subreddit could go here, or not.</p>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="subreddit/index">
<p>
All of the details of the subreddit go here, this will be rendered
into the {{outlet}} of "subreddit".
</p>
</script>
<script type="text/x-handlebars" data-template-name="link">
<p>
Link view goes here. This template will replace "subreddit/index"
in the {{outlet}} of "subreddit".
</p>
</script>