在您的主要位置
app.js或所在位置:
快递4.x
if (app.get('env') === 'development') { app.locals.pretty = true;}快递3.x
app.configure('development', function(){ app.use(express.errorHandler()); app.locals.pretty = true;});快递2.x
app.configure('development', function(){ app.use(express.errorHandler()); app.set('view options', { pretty: true });});我输入漂亮的字样是
development因为您希望通过使用“丑陋”来提高效率
production。
NODE_ENV=production在生产中进行部署时,请确保设置环境变量。可以
sh使用您在的“脚本”字段中使用
package.json并执行以开始的脚本来完成此操作。
Express 3 对此进行了更改,因为:
不再需要“视图选项”设置,app.locals是与res.render()合并的局部变量,因此[app.locals.pretty =
true与传递res.render(view,{ :true})。



