是否有可能有一条不呈现任何模板而只是做某事的路线?
这是我正在寻找的功能:
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');
},
});
如果没有,有没有办法实现这个功能?
当然,您可以覆盖路由中的默认操作。路由的默认操作是runRouteController 的方法。您在 0.5.4 中通过为handler路由提供选项来覆盖它。在 dev 分支中,您只需提供一个action选项。默认操作呈现主模板,然后将所有收益模板呈现到它们的适当位置。但是你的动作函数可以做任何你想做的事情,包括根本不渲染任何模板。我将展示 0.5.4 和开发示例:
v0.5.4
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
});
}
});