在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是否是提交函数中的解决方案?在数据被传送之后,我该怎么称呼它呢?
发布于 2019-11-07 20:15:38
我不知道向salesforce发送数据到底意味着什么,但我假设这只是一个简单的http post调用。在这种情况下,有多种方法可以做到这一点,我能想到的简单方法是:
methods: {
async submitForm() {
try {
await sendDataToSalesforce();
window.open('path.to.pdf');
} catch(err) {
// handle error
}
}
}另一个解决方案是使用应许。
https://stackoverflow.com/questions/58753363
复制相似问题