Sai Karthik

Balancing the braces ...

Reset HTML Forms Using Vue Refs

August 11, 2023 | 1 minute read

Vue refs come handly when we want to access DOM elements directly. You can read more about vue refs here

In this case, we want to reset a form. So, let’s assign a html attribute named ref to a <form> tag

A simple example:

<form ref="myForm">

Now we can apply DOM methods to an element like reset() on this form by calling this.$refs.myForm.reset()

Comment |
Tags: vue