簡體   English   中英

app.use(“ /”,express.static)和app.use(express.static)之間有區別嗎?

[英]Is there a difference between app.use(“/”, express.static) and app.use(express.static)?

假設我們首先調用了app.set('thePath', thePath) ,以下內容之間是否有區別?

  1. app.use('/', express.static(thePath))
  2. app.use(express.static(thePath))
  3. 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM