我的koa@next
应用程序具有以下结构。我koa-router@next
用于路由:
./app.js
const Koa = require('koa');
const router = require('koa-router')();
const index = require('./routes/index');
const app = new Koa();
router.use('/', index.routes(), index.allowedMethods());
app
.use(router.routes())
.use(router.allowedMethods());
module.exports = app;
./routes/index.js
const router = require('koa-router')();
router.get('/', (ctx, next) => {
ctx.body = 'Frontpage';
});
router.get('/hello', (ctx, next) => {
ctx.body = 'Hello, World!';
});
module.exports = router;
我在路线上遇到Not Found
错误。/hello
依赖版本:
"dependencies": {
"koa": "^2.0.0-alpha.7",
"koa-router": "^7.0.1",
},
与koa-router
v7.1.0 相同。
感谢您的帮助!