Vue Element of form reset

Implementation process

First of all, came to the Element's official website, find the bottom part of the Form Methods Form Form provided
[Note] here is not necessary, you can directly see the following implementation steps
Here Insert Picture Description

resetFields reset of the entire form, resets all field values ​​and the initial value of the verification results removed

Then, we started working to achieve it

The first step: get a reference to an object

Add in from the ref="loginFormRef"(loginFormRef custom name), then you can get the form to form by this instance it

ref DOM element is used to register the reference information or subassemblies. Reference information will be registered under $ refs object's parent component. If you use on a regular DOM elements, references to information that is elemental; if used in sub-assemblies, reference information is a component instance
Note: Whenever you want to directly manipulate DOM elements in Vue, it must be registered with the ref attribute

Here Insert Picture Description

Step Two: Write Click event method

Here Insert Picture Description
This completes

Knowledge supplement

  • resetFields
  • and $ ref ref
    Here Insert Picture Description
    Here Insert Picture Description
    Here Insert Picture Description
Published 30 original articles · won praise 3 · Views 3912

Guess you like

Origin blog.csdn.net/qq_41956139/article/details/104024089
Recommended