ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] ### Koa2 路由前缀 ~~~ const router = new Router(); const PostsRouter = new Router({prefix: '/posts'}); // xxx.com/posts PostsRouter.get('/', (ctx) => { ctx.body = { title: '文章首页' } }) // xxx.com/posts/1 PostsRouter.get('/:id', (ctx) => { ctx.body = { id: ctx.params.id, title: '文章列表' } }) app.use(PostsRouter.routes()) ~~~ >[danger] prefix: '/xxx' 路由前缀