随笔分类 - koa2
摘要:Koa 中间件采用的是洋葱圈模型,每次执行下一个中间件传入两个参数 ctx 和 next,参数 ctx 是由 koa 传入的封装了 request 和 response 的变量,可以通过它访问 request 和 response,next 就是进入下一个要执行的中间件。 自定义中间件m1, m2,
阅读全文
摘要:const router = require("koa-router")(); router.get("/", async (ctx, next) => { global.console.log("index8"); await ctx.render("index", { title: "Hello
阅读全文
摘要:1、安装脚手架 npm install -g koa-generator 2、创建目录 koa2 -e koa2-learn e为ejs 3、cd koa2-learn 4、npm install (安装依赖) 5、npm start 看到 > node bin/www 表示已经成功运行 local
阅读全文