I
I
iBird Rose2020-07-16 19:34:40
Vue.js
iBird Rose, 2020-07-16 19:34:40

How to properly save a form in vue?

Got a project on vue. I'm not familiar with vue. It seems like a simple task, but Google did not give anything.
In general, tell me how to save the form correctly when submitting (for starters, I just want to state).
Conditionally there is a modal, it has a lot of inputs. At the bottom of the modal is the "Save" button.
I write the input values ​​​​through: value, because through v-model it will save them immediately. And I don't need it.
So, how can I save all the form data in the required state after submitting the form? I will not prescribe for each input ref and assign values ​​one by one in the submit function. How is it done correctly?
ps I submit through <form @submit.prevent="saveModal">, if suddenly this is important

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-07-16
@iiiBird

I write the input values ​​​​through: value, because through v-model it will save them immediately.

Will not. If you make a copy of the form data object, and use the v-model properties of the copy. And on submit, update the original with the values ​​from the edited copy. For example .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question