现在我有方法:
let newFormData = {
productName: this.productName,
productModel: this.productModel,
prodDescription: this.prodDescription,
prodPrice: this.prodPrice,
promoPrice: this.promoPrice
};
console.log(newFormData);
e.target.reset();
},
我想将此表单数据发送到文件,并将其另存为json中的变量
答案 0 :(得分:1)
首先,您应该有一条路线将此表单数据提交到,然后可以像这样提交表单:
axios.post('http://localhost:3030/api/new/post',
this.productName,
this.productModel,
this.prodDescription,
this.prodPrice,
{ headers: {
'Content-type': 'application/x-www-form-urlencoded',
}
}).then(response => ....);