koa中间件

1
2
3
4
5
6
7
8
9
10
11
12
13
function pv(ctx){
global.console.log(ctx.path);
}
module.exports=function(){
return async function(ctx,next){
pv(ctx);
await next(); //next是继续执行下面的中间件,如果不写会直接跳出,不会继续执行
}
}

// app.js文件
const pv = require('./middleware/koa-pv');
app.use(pv())
#

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×