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