node.js,express入门看详细篇

先最简单的代码

安装 npm install express

app.js 代码内容

const express = require('express') const app = express() //单项流动 const mid1 = () => (req, res, next) => { res.body = '请求1<br/>' next() } const mid2 = () => (req, res, next) => { res.body += '请求2<br/>' next() } const mid3 = () => (req, res, next) => { res.body += '请求3<br/>' next() } app.use(mid1()) app.use(mid2()) app.use(mid3()) app.get('/', (req,res,next) => { res.send(res.body +'业务处理中') }) app.listen(2334)

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzpzsg.html