0
const router2 = new KoaRouter();
router2.get(`/test`, async function(ctx, next) {
ctx.body = 'api test';
});
const router = new KoaRouter();
router.get(`/1`, router2.routes(), router2.allowedMethods());
router.get(`/test`, async function(ctx, next) {
ctx.body = 'test';
});
127.0.0.1:300/test
兴亚路由器工作不筑巢
127.0.0.1:300/1/test
不起作用
我看不出问题吗?
我认为它应该是'router.use( '/ 1',异步函数(CTX,下一个){ ctx.body = '测试'; });' –
检查此以了解更多信息的https:// github.com/alexmingoia/koa-router#nested-routers –
@DeendayalGarg我已经看过了,但我想不写下路由器的完整路径。如果你明白我的意思,我希望它更“模块化”。 –