我在routes.js文件中有很多路由,我想在其中引入一个额外的字段。以下是路线
Router.route('/', {
name: 'home',
controller: 'LoginController',
where: 'client',
action:'index'
});
由于我有很多路线,我想通过所有路线并获得这样的路线名称
_.each(Router.routes, function(route){
console.log(route.getName());
});
我想使用路由名称来生成链接。链接需要链接名称,我想把链接名称放在路由中。
Router.route('/', {
name: 'home',
controller: 'LoginController',
where: 'client',
text: 'Login Link',
action:'index'
});
在流星允许的路线中引入自定义字段吗?
答案 0 :(得分:0)
我发现有一个title
选项,但它不在文档中http://iron-meteor.github.io/iron-router/#route-specific-options
并以这种方式使用
Router.route('/', {
name: 'login',
controller:'HomeController',
where: 'client',
title: 'login',
icon: 'this is the icon',
action:'index'
});
并获取选项
Router.routes.forEach(function(route){
console.log(route.getName());
console.log(route.options.title);
console.log(route.options.icon);
});
这是结果
login
login
this is the icon
所以即使自定义选项icon
似乎也有效。