在HTML验证后提交表单时,我需要将数据发送到Salesforce并打开指向PDF文件的链接。该表单是模式表单,并从父组件接收数据。
<form
class="mt-6"
@submit.prevent="submitForm(true)"
>
<button type="submit"><a :href="'/cms/+data.id+'.pdf' /></button>
</form>
methods: {
submitForm() {
console.log(
'Name is ' +
this.user.name +
' and the email id is ' +
this.user.email +
' and the download file ID is ' +
this.data.id
)
}
}
window.open
是否是提交功能中的解决方案?数据传输后如何称呼它?]
我不确定向salesforce发送数据的确切含义,但是我认为这只是一个简单的http post调用。在这种情况下,有多种方法可以实现,我可以想到的简单方法是:
methods: {
async submitForm() {
try {
await sendDataToSalesforce();
window.open('path.to.pdf');
} catch(err) {
// handle error
}
}
}
另一种解决方法是使用Promises。