前端实现导出进行&拼接逻辑和解决导出excel 加号变成空格的问题(进行转义)
导出excel进行&拼接
var newFormValue = {
name:'text',
startDate: '2021-09-10'
endDate: '2021-09-14',
age:14
};
let target = '';
const key = Object.keys(newFormValue);
const value = Object.values(newFormValue);
for (let [index, item] of value.entries()) {
target += key[index] + '=' + value[index] + '&';
}
// 进行转义,可省略
let selectListEncode = encodeURIComponent(target);
//domainConfig :域名地址
const path = domainConfig + `/getExcel?${target}`;
window.location.href = path;
如何解决导出excel 加号变成空格的问题?
进行转义:encodeURIComponent(target)