问题 :
app.set放在外面和放在app.configure里面有什么区别
答案:
以下摘自 express 3.0 的 文档
|
里面说 app.configure 是以前的版本遗留下来的,完全可以用条件判断语法取代。
文档里还举例说明了:
app.configure(function() { app.set('title', 'My Application');});
和
app.set('title', 'My Application');
是等价的,都是对所有环境有效。而
app.configure('development', function(){ app.set('db uri', 'localhost/dev');})
和
if ('development' == app.get('env')) { app.set('db uri', 'localhost/dev');}
是一个效果。