2

我想如何将中间件应用于 koa-route 中的所有路径,例如

router1.use( (ctx) => {
    console.error("hello 0 ...");
    console.log(ctx.url);
}
router1.all( (ctx) => {
    console.error("hello 0 ...");
    console.log(ctx.url);
}

它像这样返回路径 += str.slice(index, offset) ^

TypeError: str.slice is not a function 有什么提示吗?谢谢!

4

1 回答 1

0

我希望是这样

router1.use(/(.*)/, (ctx) => {
    console.error("hello 0 ...");
    console.log(ctx.url);
}
于 2017-09-14T14:05:39.197 回答