Open shfshanyue opened 3 years ago
代码见: 多匹配路由 - codesandbox
const app = new Koa() const router = new Router() router.get('/', (ctx, next) => { ctx.body = 'hello, world' }) router.get('/api/users/10086', (ctx, next) => { console.log(ctx.router) ctx.body = { userId: 10086, direct: true } }) router.get('/api/users/:userId', (ctx, next) => { console.log(ctx.router) ctx.body = { userId: ctx.params.userId } }) app.use(router.routes())
TODO
代码见: 多匹配路由 - codesandbox