问题
接口成功后返回 form 等一堆码
但不跳转
<form name="punchout_form" method="post" action="https://openapi.alipay.com/gateway.do?app_cert_sn=78b35e11ea21431114619365ac443f29&charset=UTF-8&alipay_root_cert_sn=687b59193f3f462dd5336e5abf83c5d8_02941eef3187dddf3d3b83462e1dfcf6&method=alipay.trade.page.pay&sign=UGxkPWF5w0hhMI0cUu%2BZPJZE3LCs%%2B81WCeM1P6mOqeXwToIqeL4NP1Gm6%2FzP%%2Fq3gtve%2BLJhvUpdgtZHOlvPPnohecyRiD5touIdee7%2BRgk6N35Zb53J3RTMLuWEml%3D%3D&return_url=http%3A%2F%2Fwww.yinongpuhui.com&notify_url=https%3A%2F%2Fwww.yinongpuhui.com%3A8000%2Forder%2FaliPayCallback&version=1.0&app_id=2021001129646221&sign_type=RSA2&timestamp=2020-09-16+15%3A24%3A53&alipay_sdk=alipay-sdk-java-4.8.73.ALL&format=json">
 <input type="hidden" name="biz_content" value="{&quot;out_trade_no&quot;:&quot;20200916152453160733&quot;,&quot;total_amount&quot;:&quot;80.00&quot;,&quot;subject&quot;:&quot;product_code&quot;:&quot;FAST_INSTANT_TRADE_PAY&quot;}">
 <input type="submit" value="立即支付"  >
</form>
解决

页面中加一个divform标签 (以下代码放在接口成功的位置)

//支付宝支付
 // 添加之前先删除一下,如果单页面,页面不刷新,添加进去的内容会一直保留在页面中,二次调用form表单会出错
 let divForm = document.getElementsByTagName('divform')
    if (divForm.length) {
        console.log('divForm.length')
        /*document.body.removeChild(divForm[0])*/
        document.getElementsByTagName.innerHTML = ""; // 不清除会出错
 }
 const div=document.createElement('divform');
 div.innerHTML=response; // data就是接口返回的form 表单字符串
 document.body.appendChild(div);
 document.forms[0].setAttribute('target', '_blank') // 新开窗口跳转
 document.forms[0].submit();
/*

Tong_sunshine
62 声望10 粉丝

看看看! 再看把你眼珠子抠掉!