84669 人が学習中
152542 人が学習中
20005 人が学習中
5487 人が学習中
7821 人が学習中
359900 人が学習中
3350 人が学習中
180660 人が学習中
48569 人が学習中
18603 人が学習中
40936 人が学習中
1549 人が学習中
1183 人が学習中
32909 人が学習中
koa deprecated Support for generators will been removed in v3. See the documentation for examples of how to convert old middleware https://github.com/koajs/koa/tree/v2.x#old-signature-middleware-v1x---deprecated,求解?
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
是你仍然在用传统的 1.x 里的生成器语法才会出现这条提示,是 koa 善意的提醒啦,避免以后升到 v3 你的代码就瘫痪了!所以如果你仍然继续想使用生成器语法的话就借助 co 模块吧!
官方的栗子:
app.use(co.wrap(function *(ctx, next) { const start = new Date(); yield next(); const ms = new Date() - start; console.log(`${ctx.method} ${ctx.url} - ${ms}ms`); }));
PS:既然你都用 v2 了,为啥不 async / await 用起来呢!
找到方法了 npm install koa-convert --save
import convert from 'koa-convert'
app.use(convert(require('koa-static')(__dirname + '/public')));
是你仍然在用传统的 1.x 里的生成器语法才会出现这条提示,是 koa 善意的提醒啦,避免以后升到 v3 你的代码就瘫痪了!所以如果你仍然继续想使用生成器语法的话就借助 co 模块吧!
官方的栗子:
PS:既然你都用 v2 了,为啥不 async / await 用起来呢!
找到方法了 npm install koa-convert --save
import convert from 'koa-convert'
app.use(convert(require('koa-static')(__dirname + '/public')));