极客时间返利平台,你可以在上边通过山月的链接购买课程,并添加我的微信 (shanyue94) 领取返现。

# 判断以下路由,将会响应哪一个路由

更多描述

代码见: 多匹配路由 - codesandbox (opens new window)

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());

Issue

欢迎在 Gtihub Issue 中回答此问题: Issue 621 (opens new window)

TODO

Last Updated: 11/27/2021, 6:11:48 PM