Search⌘ K
AI Features

Methods in Vue.js

Explore how to define and use methods in Vue.js instances. Understand how to pass arguments, access data with the this keyword, and call methods from templates to build interactive SPA features.

We'll cover the following...

The methods property in the Vue instance contains the definitions of all the functions that the Vue instance can perform. This is similar to vanilla JavaScript methods/functions as they can also be defined anywhere and can be called when needed or when a specific event occurs. However, in the Vue instance, its functions can only be defined in the methods property.

Method syntax

Like JavaScript methods, Vue.js methods can be defined as functionName(){...}. A sample method defined while using this syntax is shown below. ...