2
我想航線在多個文件中路線與多個文件的NodeJS
var routes=require('./routes');
在路線
/index.js
exports.inicio=require('./inicio')
exports.home=require('./home')
在inicio.js
exports.index=function(req,res){res.render('index/index',{title: 'Bienvenido a Inmoweb'});}
在home.js
exports.nosotros=function(req, res){res.render('index/nosotros',{title:'Nosotros'});}
當我CONSOLE.LOG(路由)
{
inicio: {index:[function]},
home: {nosotros:[function]}
}
,所以我呼籲在應用
app.get('/',routes.inicio.index);
,但我想這樣
app.get('/',routes.index);
app.get('/nosotros',routes.nosotros);
和執行console.log supose調用成爲????
{
index:[function],
nosotros:[function]
}
怎麼辦? TNX所有
這不是答案,但我解決了我的問題與你的幫助謝謝 – andrescabana86 2012-08-13 16:30:27
安德烈,你的解決方案是什麼。如果你更詳細地說明你是如何解決問題的,那將會有所幫助。我認爲rdrey的解決方案和解釋非常好。 – TechplexEngineer 2012-12-22 04:22:52