我有一个对象
this.requestData = {
flightto: 'CGK',
flightfrom: 'DPS',
flightdate: '06-04-2018',
flightpp: 0,
flightadult: 1
};
console.log((<any>Object).entries(this.requestData));
如果我执行console.log(),如何使该对象成为
flightto = CGK&flightfrom = DPS&flightdate = 06-04-2018&flightpp = 0&flightadult = 1
答案 0 :(得分:0)
如果要连续输出,请尝试此操作
let dataString = "";
Object.keys(this.requestData).forEach(key => {
dataString+=`${key}=${this.requestData[key]}&`;
});
console.log(dataString);
或者您可以在循环内进行控制台
Object.keys(this.requestData).forEach(key => {
console.log(`${key}=${this.requestData[key]}&`);
});