我在前几页的工作中不知道这是不起作用的。
console.log("value " + req.body["names[]"]);
我想在服务器中检索该值。在我的其他页面中,我使用此
public static void MoveForm(this Form form, Screen screen = null)
{
if(screen == null)
{
//If we have a single screen, we are not moving the form
if(Screen.AllScreens.Length > 1) return;
screen = Screen.AllScreens[1];
}
var bounds = screen.Bounds;
form.Left = ((bounds.Left + bounds.Right) / 2) - (form.Width / 2);
form.Top = ((bounds.Top + bounds.Bottom) / 2) - (form.Height / 2);
}
我通常会得到一系列名字。现在由于某些原因我得到的都是未定义的我已经尝试了几个小时我只是不知道出了什么问题。
答案 0 :(得分:1)
req.body
默认为undefined
。您需要像Express Docs这样的中间件来抓取req
的内容。
1)npm install body-parser
2)在服务器文件的顶部 - var bodyParser = require('body-parser');
3)在var app = express()
包含app.use(bodyParser.json());