1. makeForm(data) {
    2. // 创建一个 form
    3. const tempForm = document.createElement("form");
    4. tempForm.id = "tempForm";
    5. tempForm.name = "tempForm";
    6. tempForm.target = "_blank";
    7. // 添加到 body 中
    8. document.body.appendChild(tempForm);
    9. // 创建一个用户名输入
    10. const nameinput = document.createElement("input");
    11. // 设置相应参数
    12. nameinput.type = "text";
    13. nameinput.name = data.fromParamName;
    14. nameinput.value = data.fromParamValue;
    15. // 将该输入框插入到 form 中
    16. tempForm.appendChild(nameinput);
    17. // form 的提交方式
    18. tempForm.method = "POST";
    19. // form 提交路径
    20. tempForm.action = data.redirectUrl;
    21. // 对该 form 执行提交
    22. tempForm.submit();
    23. // 删除该 form
    24. document.body.removeChild(tempForm);
    25. }