1)因为express将body-parser分离了出来,所以你需要手动添加进下面的内容即可

var path = require('path');
var bodyParser = require('body-parser');//用于req.body获取值的
app.use(bodyParser.json());
// 创建 application/x-www-form-urlencoded 编码解析
app.use(bodyParser.urlencoded({ extended: false }));

 

2)如果你传输的内容不是string类型时,你需要对上面的配置进行修改:

app.use(bodyParser.urlencoded({ extended: true}));

否则也总是会得到undefined的结果

相关文章:

  • 2022-12-23
  • 2021-10-24
  • 2022-12-23
  • 2022-12-23
  • 2021-08-31
  • 2021-12-23
  • 2022-12-23
  • 2021-10-26
猜你喜欢
  • 2022-12-23
  • 2021-07-23
  • 2022-12-23
  • 2022-02-20
相关资源
相似解决方案