The problem of form reset validation in vue+element-ui

clipboard.png
1, this is a vue pop-up layer
2, as shown in the figure, element-ui [how to cancel the triggered validation at the click of the close button].

=
update on March 13, 2018.013

1, for the reset style, please see the adopted answer
2. When the submission is successful, you can execute the following reset statement to reset it. Solved the problem that there is no reset when you click again when the submission is successful.
this.$refs ["Form"] .fields ()

=
Update on August 24, 2018.08

parent test is available. Thank you
this.$refs ["Form"] .clearValidate () / / reset validation


I've done something similar before, adding a ref attribute to form when I click close, as I said on the 2nd floor, and then write this.$refs ['refname'] .cancel Fields () in the cancel event. You can also add the following code to the event that the form ref attribute = refname;
modal box opens when the this.$refs ['refname'] .fields (), can also achieve the effect


when the pop-up layer is just opened.
this.$nextTick (() = > {/ / wait for dom Synchronize to open the mode box
this.$refs ['refname'] .fields (); / this method needs to be loaded in the modal box before
})


this.$refs.form.reset ()


as written on the first floor, you add a ref attribute to form, and then write this.$refs ['refname'] .deleted Fields ()


you should use clearValidate, ref to lead to the form instance, and call that method

< hr class= "in js.
  1. use this.$refs instead of this.$ref
  2. with this.$nextTick (() = > {})
  3. model / ref in el-form and prop in el-form-item check it again
< hr >

10:55:49 on June 30, 2020

Menu