koa的api中貌似并没看到关于router的用法,看了npm 中关于koa-router的用法,一脸懵逼我是这么写的,求大神解释const Koa = require("koa");const koaRouter = require("koa-router");var app = new Koa();var router = new koaRouter();app.listen(5599);router.get('/', function (ctx, next) {ctx.response.body = 'hello';});app.use(router.routes()).use(router.allowedMethods());
添加回答
举报
0/150
提交
取消