如何确定Ember 2中的活动子路线? [英] how to determine active child route in Ember 2?

查看:60
本文介绍了如何确定Ember 2中的活动子路线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,说我有


  • 主从设置(小部件路线,带有嵌套的Widget路径)

  • 在我建模的主模板中,它是 Widget.all 将其列为 {{link-to}} 的列表,每个列表都转换为 widgets.widget 路线

  • a master-detail setup (a Widgets route, with a nested Widget route)
  • in the master template I model, which is Widget.all to a component that lays it out as a list of {{link-to}} each of which transitions to the widgets.widget route

...然后在灰烬2中建议使用哪种方式来告诉该组件所选的小部件是什么,以便它可以突出显示其链接?

...then what is/are the recommended way(s) in ember 2 to tell that component what the selected widget is, so it can highlight its link?

推荐答案

Ember的路由基础结构会自动处理将活动类添加到链接的情况(前提是您正在使用链接)

Ember's routing infrastructure automatically handles adding active classes to links provided you're using the link-to helper.

请参见 emberjs-如何使用路由器基础结构标记活动菜单项

如果您想使用锚标签之外的标签,像li一样,请参阅: stackoverflow.com/questions/16380523/create-a-li-class-active-around-an-active-linkto>创建< li class = active>。围绕有效的{{linkTo}}

If you want to use a tag besides an anchor tag, like an li, see: Create a <li class="active"> around an active {{linkTo}}

这篇关于如何确定Ember 2中的活动子路线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆