(express.js)有什么app.set函数?
我是node.js的新手,正在通过一个示例无法理解app.set('title','My Site');请帮忙吗?
I am new to node.js and was going through an example could not understand app.set('title', 'My Site'); does please help?
您可以使用express实例存储和检索变量.在这种情况下,您可以将标题设置为我的网站",以后再使用类似的
You can use the express instance to store and retrieve variables. In this case, you can set the title to be "My Site" and retrieve it later with something like
var title = app.get('title');
无需声明和保留全局变量.
without the need to declare and keep a global variable messing around.
参数名称没有任何意义.您可以
The name of the parameter means nothing. You could do
app.set('jabberwocky', 'correct battery horse staples');
也是.例如,如果您将翡翠用于玉器,则可能需要在模板中沿线检索"jabberwocky"的值.
as well. If you're using express with jade, for example, you might need to retrieve the value of 'jabberwocky' in a template, further along the line.