Maik Lowrey
Maik Lowrey

Reputation: 17566

Vue different methods notation

What is the difference between these two notations? For example:

...
methods: {
  makeAuthorList() {
    return ...
  },
}
...

and

...
methods: {
  makeAuthorList: function(){
    return ...
  },
}
...

Upvotes: 1

Views: 114

Answers (2)

Javier Heisecke
Javier Heisecke

Reputation: 1222

functionally they don't have a difference, they do the exact same thing, this way:

nameOfFunction: function(){}

is just a long way to define your methods, so they added a second way to define methods which is a shorter version, just so save time

nameOfFunction() {}

best pratices vuejs

Upvotes: 1

Gaetan C.
Gaetan C.

Reputation: 1904

Both are identical, the first one is just a shorter syntax for method definitions starting with ES2015. Take a look at this article from the MDN docs.

Upvotes: 1

Related Questions