【发布时间】:2013-01-29 12:46:42
【问题描述】:
我想创建 2 个页面,使用 2 个玉文件。以下方式有什么问题:
exports.index = function(req, res){
res.render('index', { title: 'Welcome' });
};
exports.room = function(req, res){
res.render('room', { title: 'Game' });
};
索引localhost:3000 有效。但是localhost:3000/room 给了我
Cannot GET /room
【问题讨论】:
-
您的主要
app.js文件看起来如何?你有app.get('/room', routes.room)路线或类似的东西吗? -
@zeMirco 是的,我现在做到了,它解决了问题。你可以写作为答案。我必须为每一页做吗?如果我有很多页面怎么办,有没有办法获取
index.js路由文件中的所有页面?