const Koa = require('koa')
const static = require('koa-static')
const path = require('path')
const app = new Koa()
const test1 = async (ctx, next) => {
console.log('test1')
await next()
}
const test2 = (ctx, next) => {
console.log('test2')
next()
}
app.use(static(path.join(__dirname, 'dist')))
app.use(test1)
app.use(test2)
app.listen(8999, () => {
console.log(8999)
})
进入localhost:8999后,test1,test2两个中间件没有被触发
跟koa-static调换位置之后
app.use(test1)
app.use(test2)
app.use(static(path.join(__dirname, 'dist')))
test1,test2两个中间件触发了,但koa-static没被触发。
难道koa-static没有next()么,并且为何调换位置后koa-static也触发不得
慕莱坞森
相关分类