所以我在Bootstrap-3 中找到了这个导航栏功能,但到目前为止我使用的是 Flow-Router 而不是 Iron-Router。因此,我正在寻求将这个辅助函数转换为 Flow-Router 术语:
Template.navItems.helpers({
activeIfTemplateIs: function (template) {
var currentRoute = Router.current();
return currentRoute &&
template === currentRoute.lookupTemplate() ? 'active' : '';
}
});
我已经尝试解决问题(虽然没有费心对其进行测试,因为我的网站/应用程序的许多部分仍然无法运行),但我需要以“是”或“否”的形式进行确认,并且也许更多关于我做错了什么的信息。
Template.navItems.helpers({
activeIfTemplateIs: function (template) {
var currentRoute = FlowRouter.current();
return currentRoute &&
template === currentRoute.name ? 'active' : '';
}
});
我从Flow-Router API引导自己。这个解决方案是正确的,还是出于某种原因或其他严格地必须与 Iron-Router 一起使用?