如何在机车Js的控制器中使用send()。我认为LCM只提供render()。 有人可以在这方面指导我。
答案 0 :(得分:2)
Locomotivejs只是Express的扩展,这意味着Loco应用程序是Express应用程序。来自文档:
请求和响应
如果应用程序需要访问原始请求和响应,则每个应用程序都可以作为控制器中的实例变量。
PhotosController.show = function() { var req = this.req; // also aliased as this.request var res = this.res; // also aliased as this.response this.render(); }
所以在你的控制器中,只需:
MyController.myAction = function () {
this.res.send(200);
}