1 get

1-1 get传值

  1. locahost?start=0;
  1. ctx.request.query //后台获取

1-2 动态路由

  1. //后台配置
  2. router.get(/subject/:id,async ctx=>ctx.body="xxx")
  1. ctx.request.params //后台获取动态路由的书

2 post

安装依赖

  1. npm i koa-bodyparser -S
  1. var Koa = require('koa');
  2. var bodyParser = require('koa-bodyparser');
  3. var app = new Koa();
  4. app.use(bodyParser());
  5. app.use(async ctx => {
  6. ctx.body = ctx.request.body;
  7. });