有没有可能有一条不渲染任何模板而只做一些事情的路由?
这就是我想要的功能:
this.route( {
path: '/something/:info1/:info2',
method: function() {
// do something with this.params.info1 and this.params.info2
Router.go('elsewhere');
},
});如果没有,有没有办法实现这个功能呢?
发布于 2013-09-25 14:18:50
当然,您可以覆盖路由中的默认操作。路由的默认操作是RouteController的run方法。在0.5.4中,您可以通过为路由提供handler选项来覆盖它。在dev分支中,您只需提供一个action选项。默认操作将呈现主模板,然后将所有产量模板呈现到其正确的位置。但是你的action函数可以做任何你想做的事情,包括根本不渲染任何模板。我将展示0.5.4和dev示例:
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
});
}
});https://stackoverflow.com/questions/18521676
复制相似问题