gpt4 book ai didi

javascript - 根据路线决定渲染到哪个导出

转载 作者:行者123 更新时间:2023-11-29 19:43:01 25 4
gpt4 key购买 nike

所以我的 Handlebars 标记中有两个不同的 socket 。一个 socket 未命名 {{outlet}},一个名为 {{outlet modal}}(我在 Ember Cookbook 中实现了一个模态)。

我正在制作的应用程序的一个要求是模式中显示的内容应该是可链接的。例如,资源“汽车”应该出现在那里。我可以弄清楚如何建立到 /cars/52 的链接并让它在那个导出呈现,但我如何制定这样的路线规则?

你怎么能说出一条路线(如 /cars/:car_id)在特定导出呈现?

最佳答案

请注意,当您开始渲染到不同的 socket 时,您需要确保 socket 也被渲染(也就是它是当前路由的父级,例如应用程序)。

App.CarsRoute = App.Route.extend({
renderTemplate: function() {
this.render('cars', { // the template to render
into: 'application', // the route to render into
outlet: 'modal', // the name of the outlet in the route's template
controller: 'cars' // the controller to use for the template
});
}
});

http://emberjs.com/guides/routing/rendering-a-template/

关于javascript - 根据路线决定渲染到哪个导出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21843325/

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