gpt4 book ai didi

javascript - emberjs 中的嵌套路由而不使用资源导出

转载 作者:搜寻专家 更新时间:2023-11-01 04:09:59 25 4
gpt4 key购买 nike

我有一个路由器,每个路由(和路由对象)都有相应的模板。我希望能够独立于其父模板显示每个模板,这意味着我不希望将嵌套路由呈现到父模板的导出。本质上是为每个嵌套路由创建一个单独的“页面”。

App.Router.map(function() {
this.resource('recipes', function() {
this.route('new');
this.route('show', { path: '/:recipe_id' });
});
});

我正在使用 ember1.0.0-rc1

谢谢

最佳答案

I want to be able to display each template independently of its parent, meaning I don't want the nested routes to be rendered to the parent template's outlet.

也许这是显而易见的,但如果您不为资源创建模板,就会发生这种情况。在您的情况下,如果您不创建 recipes.hbs 模板,那么 ember 会将 new.hbsshow.hbs 模板渲染到application.hbs 中的 {{outlet}}

注意:如果您这样做,Ember 将输出一个控制台警告“直接父路由没有渲染到主导出......”

这在 ember routing guide 中有更详细的解释。

关于javascript - emberjs 中的嵌套路由而不使用资源导出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15399944/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com