Ash*_*ane 7 ember.js ember-cli
我有两个嵌套这样的路线.
router.js
this.route('profile', function() {
this.route('edit');
});
Run Code Online (Sandbox Code Playgroud)
像这样的这些路线的几个导航栏链接..
navbar.hbs
{{#link-to 'profile' tagName="li"}}<a href>View Profile</a>{{/link-to}}
{{#link-to 'profile.edit' tagName="li"}}<a href>Edit Profile</a>{{/link-to}}
Run Code Online (Sandbox Code Playgroud)
该link-to助手添加active类到li这里的标签.因此,当我在profile路线时,第一个链接有active类,当我在profile.edit路线时,两个链接都有active类.(显然是因为profile.edit访问时两条路线都被激活了.)
如何在子路由中避免父路由链接获取active课程?
基本上我不希望第一个链接(to profile)active在profile.edit路线上有课.
Ash*_*ane 14
我想是否有其他人面临同样的问题.
我只是将链接更改profile为明确的profile.index.
navbar.hbs
{{#link-to 'profile.index' tagName="li"}}<a href>View Profile</a>{{/link-to}}
{{#link-to 'profile.edit' tagName="li"}}<a href>Edit Profile</a>{{/link-to}}
Run Code Online (Sandbox Code Playgroud)
这样,在profile.edit路由中,第一个链接不会获得active类.