vue/react/js 提交form表单

//创建订单后payParams 赋值给input并通过form表单提交支付

markFormSubmit(payParams){ var form1=document.createElement("form"); form1.id="form1"; form1.name="form1"; form1.target="_self"; form1.setAttribute("target","_self"); document.body.appendChild(form1); var input = document.createElement("input"); input.type="hidden"; input.name="orderType"; input.value=payParams.orderType; form1.appendChild(input); var input1 = document.createElement("input"); input1.type="hidden"; input1.name="amount"; input1.value=payParams.amount; form1.appendChild(input1); var input2 = document.createElement("input"); input2.type="hidden"; input2.name="tradeNum"; input2.value=payParams.tradeNum; form1.appendChild(input2); var input3 = document.createElement("input"); input3.type="hidden"; input3.name="sign"; input3.value=payParams.sign; form1.appendChild(input3); //微信环境添加input note var ua = window.navigator.userAgent.toLowerCase(); console.log(ua);//mozilla/5.0 (iphone; cpu iphone os 9_1 like mac os x) applewebkit/601.1.46 (khtml, like gecko)version/9.0 mobile/13b143 safari/601.1 if (ua.match(/MicroMessenger/i) == 'micromessenger') { var input16 = document.createElement("input"); input16.type="hidden"; input16.name="note"; input16.value=payParams.note; form1.appendChild(input16); } form1.method="POST"; form1.action="https://dddddddddd/saveOrder"; form1.submit(); document.body.removeChild(form1); }

  

原文地址:https://www.cnblogs.com/shuihanxiao/p/13815048.html