我很努力地理解express/jade的路由,我看到的所有例子都只有1頁index.html,但是如果你的網站有多個頁面呢?節點快速路由
在我的/路線文件夾中的文件index.js我有以下幾點:
exports.index = function(req, res){
res.render('index.jade', { title: 'Home'});
};
exports.sched = function(req, res){
res.render('sched.jade', { title: 'Schedules' });
};
然而,當我嘗試打開URL的sched.jade頁面不呈現:/章附表
我在做什麼錯?
如果您使用的是[生成的應用程序(http://expressjs.com/guide.html#executable),在'/ routes'目錄意用於定義應用程序的動作,而將它們綁定到它們各自的路線上[在app.js文件中完成](https://github.com/visionmedia/express/blob/3.3.1/bin/express# L235-L236)。該項目的['route-separation'示例](https://github.com/visionmedia/express/tree/3.3.1/examples/route-separation)遵循類似的概念,其中定義了'index.js'綁定操作'post.js','site.js'和'user.js'。 –
另外,儘管他們使用的是不同於Express的路由器,但是['npm-www' project](https://github.com/isaacs/npm-www)(['npmjs.org'](https:/ /npmjs.org/))仍然可以作爲使用['〜/ router.js'](https://github.com/isaacs/npm-www/blob/master/router.js)綁定進行路由分離的完整示例他們的['〜/ routes /'](https://github.com/isaacs/npm-www/tree/master/routes)。 –