好好学习 ,天天向上。Are you ready?
代码奉上!!!!!!!!!
js创建form表单 并提交
// 此处为js要模拟的标签
<form action="keyUrl" method="post">
<input name="keyOneName" value="keyOneValue" /><br>
<input name="keyTwoName" value="keyTwoValue" /><br>
<input type="submit" value="提交" />
</form>
js示例
createForm() {
let form = document.createElement('form')
form.action = this.interObj.keyUrl
form.method = 'post'
let inputOne = document.createElement('input')
inputOne.type = 'hidden'
inputOne.name = this.interObj.keyOneName
inputOne.value = this.interObj.keyOneValue
form.appendChild(inputOne)
let inputTwo = document.createElement('input')
inputTwo.type = 'hidden'
inputTwo.name = this.interObj.keyTwoName
inputTwo.value = this.interObj.keyTwoValue
form.appendChild(inputTwo)
document.body.appendChild(form)
form.submit()
},