【发布时间】:2017-11-06 20:29:39
【问题描述】:
res.render 回调参数的用途是什么?
在什么情况下需要使用这样的回调参数,因为模板已经被指定为第一个参数?
这是文档中的代码:
// send the rendered view to the client
res.render('index');
// if a callback is specified, the rendered HTML string has to be sent explicitly
res.render('index', function(err, html) {
res.send(html);
});
// pass a local variable to the view
res.render('user', { name: 'Tobi' }, function(err, html) {
// ...
});
我理解前两个参数的目的,但不是最后一个。
【问题讨论】:
标签: javascript node.js express pug