javascript - Koa即将不支持generators,那应该怎么写?
巴扎黑
巴扎黑 2017-04-11 12:53:40
0
0
437
const Koa = require('koa'),
    app = new Koa(),
    Router = require('koa-router'),
    router = new Router();

app.use(router.routes());

app.use(ctx => {
    ctx.body = 'Hello World';
});

app.listen(8000);

没有报错,但是报出一条警告:

koa deprecated Support for generators will be removed in v3. See the documentation for examples of how to convert old middleware https://github.com/koajs/koa/blob/master/docs/migration.md server.js:6:5

OK, 那么就是app.use(router.routes());这里写的不好,那么应该怎么写才对呢?事实上我甚至不太清楚这句话是做什么的~

求教,谢谢~

巴扎黑
巴扎黑

reply all(0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template