Answer the question
In order to leave comments, you need to log in
How to submit a form in VueJS?
There is a form:
<form @submit.prevent="toSend" method="POST" action="http://www.SomeAnotherSite.com">
<input v-model="param1"/>
<button type="submit">to send</button>
</form>
toSend(){
let data = {param1: this.param1}
this.http.post('site.com', data)
.then(res => {
if (res.data.check == true){
//Как сделать так, чтобы форма продолжила выполняться на 'http://www.SomeAnotherSite.com'?
// вот есть метод form.prevent, а есть ли обратная ей?
}
else
console.log('some error');
})
}
Answer the question
In order to leave comments, you need to log in
I didn't really understand. Do you want to make a request and then submit the form? If so, then after the request, just access the form and do a native submit :
toSend() {
let data = { param1: this.param1 };
this.http.post('site.com', data).then(res => {
if (res.data.check == true) {
this.$refs.form.submit();
} else {
console.log('some error');
}
})
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question