postExcelFile(params, url) { //params是post请求需要的参数,url是请求url地址
var form = document.createElement("form"); //创建form表单节点
form.style.display = 'none';
form.action = url;
form.method = "post";
form.enctype = "application/x-www-form-urlencoded;charset=UTF-8";
document.body.appendChild(form);
for(var key in params){
var input = document.createElement("input");
input.type = "hidden";
input.name = key;
input.value = params[key];
form.appendChild(input);
}
form.submit();
form.remove(); //删除form表单节点
},
onclick(){
let obj = {};
let url = 'www.baidu.com'
this.postExcelFile(obj,url) // 导出成功。
}