![](/img/trans.png)
[英]`app.use(express.static` seems to not working if app - is subapplication
[英]Is there a difference between app.use(“/”, express.static) and app.use(express.static)?
假設我們首先調用了app.set('thePath', thePath)
,以下內容之間是否有區別?
app.use('/', express.static(thePath))
app.use(express.static(thePath))
app.use(express.static(app.get('thePath')))
似乎(1)和(2)會做同樣的事情。
據我所知,在Javascript中,如果您調用的函數在被調用時會求值,因此即使app.get('thePath')
更改或thePath
更改,所有這些都將保持不變。
如果有區別,請告訴我原因和原因。
http://expressjs.com/en/4x/api.html#app.use
如果未指定路徑,則默認為“ /”。
是的,1和2是相同的。 假設thePath
是一個變量,指向靜態資產的有效根目錄。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.