简体   繁体   English

在 express.js 中设置默认路径

[英]Set a Default Path in express.js

app.set('views', path.join(__dirname,'views'))

What is the meaning of the line above?上面那一行是什么意思? And what is the purpose of it?它的目的是什么?

That line of code indicates the main path of your views, for example if you have this hierarchy:该行代码指示视图的主要路径,例如,如果您具有此层次结构:

 views/index.html views/home/index.html views/home/news/index.html

would render your views like this:会像这样呈现你的观点:

 res.render('/index.html', /*...*/); res.render('home/index.html', /*...*/); res.render('home/news/index.html', /*...*/);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM