Angular HttpClient POST传参PHP服务器获取不到参数解决办法:
1. 序列化对象或数组,返回字符串
transformRequest(data) {
var str = '';
for (var i in data) {
str += i + '=' + data[i] + '&';
}
str.substring(0, str.length - 1);
return str;
};
2. 使用transformRequest方法
this.http.post(url, this.transformRequest(param), {
headers: new HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded'
})
});