我的链接是在 Ember 2.0 上使用上述来自 Goobi 的解决方案进行的。
在我的路由器中,我有:
this.route('event', {path: '/:eventShortName'}, function(){
this.route('index', {path: '/'});
this.route('new-article', {path: 'new-article'});
this.route('page', {path: ':articleTitle'}, function(){
this.route('data', {path: ':dataId'});
});
});
每当我访问 event.page.data 时,导航栏中的所有链接都会处于活动状态。
修复前:
{{#link-to 'event.page' article.articleURL class="nav-dynamic hidden-xs" tagName="li" href=false}}
{{#link-to 'event.page' article.articleURL }}
{{article.articleTitle}}
{{/link-to}}
{{/link-to}}
修复后:
{{#link-to 'event.page.index' article.articleURL class="nav-dynamic hidden-xs" tagName="li" href=false}}
{{#link-to 'event.page.index' article.articleURL }}
{{article.articleTitle}}
{{/link-to}}
{{/link-to}}
功能保持不变,现在访问数据 url 时没有链接处于活动状态。