在react后端页面实现点击按钮,跳转到页面,如何实现呢?很简单的哟。
var url = "https://test.taobao.com/login"; let options = {}; var headers = new Headers(); headers.append( "Content-type", "APPlication/x-www-FORM-urlencoded"); options.headers = headers; options.body = res.result; options.method = "post"; options.credentials = "include"; options.mode = "cors"; return Fetch(url, options).then((response) => { });
提示跨域错误。
改为react表单提交
makeform:function(data){ //console.log(data); const Form = document.createElement('form'); form.id = 'form-file-download'; form.name = 'form-file-download'; // 添加到 body 中 document.body.appendChild(form); for (const key in query) { if (query[key]!== undefined && Object.hasOwnproperty.call(query, key)) { // 创建一个输入 const input = document.createElement('input'); input.type = 'hidden'; input.name = key; input.value = query[key]; form.appendChild(input); } } // form 的提交方式 form.method = 'POST'; //跳转新页面 form.target = '_blank' // form 提交路径 form.action = 'https://test.taobao.com/login'; form.submit(); document.body.removeChild(form); },


网友评论文明上网理性发言 已有0人参与
发表评论: