- 链式反应--next()
const myexpress = require('express'); const bodyparser = require('body-parser'); var server = myexpress(); server.listen(8080); server.use('/',function (req,res,next) { console.log('a'); req.name = "陈培昌"; next() }); server.use('/',function (req,res,next){ console.log('b'); req.intro = req.name+"芳龄"+22; next(); }); server.use('/',function (req,res,next) { console.log(req.intro) });
上机结果:
a
b
陈培昌芳龄22