带有expressjs的回叫路线
请,我需要弄清楚为什么外部callback(在diff文件中定义)分配给一个路线
app.get('/list', routes.list);
它正在工作,如果我定义
var router = express.Router(); router.get('/list', routes.list);
callback停止工作。
谢谢。
例如,您应该为您的申请申请路线
var routes = { list: function (req, res, next) { res.sendFile(path.join(__dirname, './public', 'index.html')); } }; // app.get('/list', routes.list); router.get('/list', routes.list); // apply the routes to our application app.use('/', router); app.listen(3000);