Meteor 铁路由任意法
有没有可能有一个不呈现任何模板而只是执行某些操作的路由 这是我正在寻找的功能:Meteor 铁路由任意法,meteor,meteorite,iron-router,Meteor,Meteorite,Iron Router,有没有可能有一个不呈现任何模板而只是执行某些操作的路由 这是我正在寻找的功能: this.route( { path: '/something/:info1/:info2', method: function() { // do something with this.params.info1 and this.params.info2 Router.go('elsewhere'); }, }); 如果没有,是否有办法实现此功能?当然,
this.route( {
path: '/something/:info1/:info2',
method: function() {
// do something with this.params.info1 and this.params.info2
Router.go('elsewhere');
},
});
如果没有,是否有办法实现此功能?当然,您可以覆盖路由中的默认操作。路由的默认操作是RouteControl的run方法。在0.5.4中,可以通过为路由提供处理程序选项来覆盖它。在dev分支中,您只需提供一个操作选项。默认操作渲染主模板,然后将所有屈服模板渲染到其正确的位置。但是您的操作函数可以做任何您想做的事情,包括根本不呈现任何模板。我将展示0.5.4和dev示例: v0.5.4 发展科:
您可以从location.href.提取info1和info2。。
this.route({
path: '/something/:info/:info2',
handler: function () {
var info = this.params.info;
var info2 = this.params.info2;
this.redirect('elsewhere', {
//optional context object which could include params
});
}
});
this.route({
path: '/something/:info/:info2',
action: function () {
var info = this.params.info;
var info2 = this.params.info2;
this.redirect('elsewhere', {
//optional context object which could include params
});
}
});