vue js 模拟form表单提交下载文件
const json = {};//JSON数据
const form = document.createElement("form");
form.setAttribute("method", "POST");
form.setAttribute("action", "apiUrl"); // 提交的目标地址,接口地址
for (const key in json) {
if (json.hasOwnProperty(key)) {
const input = document.createElement("input");
input.setAttribute("type", "hidden");
input.setAttribute("name", key);
input.setAttribute("value", json[key]);
form.appendChild(input);
}
}
document.body.appendChild(form);
form.submit();
如有不懂评论区留言,或者+微信:programmer-duan

浙公网安备 33010602011771号