Vue.js Watch Property

The watcher in Vue.js listens to the component data and executes when it finds changes in any property. It is an essential feature of the Vue.js framework that allows us to spy on a Vue object property, and execute a function when the computed property value changes.

Example: This example explains how we can use the watch property in the Vue.js application.

Index.Html

Output: After executing this code, we will get the output, as shown below:

Vue.js Watch Property

When we enter the course name in a textbox, it takes few seconds to show the result of its hidden data, as shown below:

Vue.js Watch Property

When we enter the values inside the textbox, whatever it gets changes, the “Watch Property” is responsible for updating the textbox. Here, we don’t have to specially define any events and wait for it to change and do the extra work of validating. Watch property is responsible for updating the textbox with the calculation performed in the respective functions.

Pin It on Pinterest

Share This