const express = require("express") const app = express() app.use(fun()) // 注意这里直接调用函数,所以直接加括号 function fun(){ return (req,res,next)=>{ console.log(req.url); console.log(req.method); next() } } app.get("/",(req,res)=>{ res.send("xsxaxasxasx") }) app.listen(80)