前端测试代码
$('#test').click(function(){
var data = {
flag:false
}
$.ajax({
url: "/test",
method: "POST",
data: data,
dataType: "json",
success:function(result){
},
error:function(xhr,error){
console.log(error);
}
});
})
node代码
app.post('/test', function(req, res) {
console.log(typeof req.body.flag);
});
我加了app.use(express.bodyParser());
结果是string,为什么不会解析成Boolean类型呢?