expressjs_ExpressJS 5.0的新增功能

expressjsExpress 5.0 is currently in the alpha release stage and it will not be quite different from Express 4. While the underlying API remains the same as that of Express 4, you may need to watch fo...
摘要由CSDN通过智能技术生成

expressjs

Express 5.0 is currently in the alpha release stage and it will not be quite different from Express 4. While the underlying API remains the same as that of Express 4, you may need to watch for some deprecated methods that may break your application when you upgrade.

Express 5.0当前处于Alpha发行阶段,与Express 4并没有太大区别。 虽然基础API与Express 4相同,但是您可能需要注意一些不推荐使用的方法,这些方法在升级时可能会破坏您的应用程序

It should, however, be a smooth transition between Express v4 and Express v5 as we will see in the following examples.

但是,这应该是Express v4和Express v5之间的平滑过渡,如以下示例所示。

We've built APIs on Express 4, so we're very excited to see that 5 is coming shortly

我们已经在Express 4上构建了API ,因此我们很高兴看到5即将推出

设置Express 5项目 ( Setting Up An Express 5 Project )

To get started, set up a new node project with npm init and install the latest Express 5 alpha release from npmjs. You can always refer to the release logs from the Express repository's history.md file.

首先,使用npm init设置一个新的节点项目,并从npmjs安装最新的Express 5 alpha版本。 您始终可以从Express资源库history.md文件中引用发布日志。

$npm install express@5.0.0-alpha.3 --save

We are now ready to see some of the changes. Most of the methods and properties that we will look at here were previously deprecated and have been completely removed in Express 5.

现在,我们准备看到一些更改。 我们将在此处介绍的大多数方法和属性以前均已弃用,并已在Express 5中完全删除。

不推荐使用的方法和属性 ( Deprecated Methods And Properties )

app.del()

app.del()

app.del() has been removed as a HTTP DELETE registration method in favor of app.delete().

app.del()已被移除为HTTP DELETE注册方法,而支持app.delete()

app.del('/resource', (req, res) => res.send('deleted'));
//4: express deprecated app.del: Use app.delete instead
//5: TypeError: app.del is not a function

app.param(fn)

app.param(fn)

The app.param(fn) signature was used for modifying the behavior of the app.param(name, fn) function. It has been deprecated since v4.11.0, and Express 5 no longer supports it at all.

app.param(fn)签名用于修改app.param(name,fn)函数的行为。 从v4.11.0开始不推荐使用它,Express 5不再支持它。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值