2015-02-08 71 views

回答

0

我發現,在config\express.js文件中,有這樣一節:

// Globbing routing files 
    config.getGlobbedFiles('./app/routes/**/*.js').forEach(function(routePath) { 
     require(path.resolve(routePath))(app); 
    }); 

它通過一個glob路徑(即'./app/routes/**/*.js')到getGlobbedFiles()功能,然後調用一個函數(即foreach)每個數組中返回的文件。每個返回的文件都是routes文件夾中的一個路徑文件。

所有路由器因此require d到應用程序。