i5ting / koa-generator

Koa' application generator for 1.x and 2.x( Express-style and support all middlewares include async/await )
https://github.com/17koa/koa-generator
MIT License
972 stars 110 forks source link

app.js 文件中关于路由的 use 问题 #66

Open xyx650 opened 3 years ago

xyx650 commented 3 years ago

使用最新的 koa-generator 生成的项目 app.js 文件中,有如下一段代码:

// routes app.use(index.routes(), index.allowedMethods()) app.use(users.routes(), users.allowedMethods())

IDE 提示 Invalid number of arguments, expected 1 查看了相关文档和 koa 源码,其中 app.use 只接收一个参数 fn。 index.allowedMethods() 等操作是否可以放在 routers 的相关文件中,在 module.exports 之前执行?