Jan 9, 2020 in Vue.JS
Q:

Why shouldn’t we use arrow functions when writing lifecycle hooks or other options/properties in a Vue instance?

1 Answer

0 votes
Jan 9, 2020

Arrow functions don’t define a ‘this’ context of their own and are instead bound to their parent function’s context. When you use an arrow function ( => ) in a Vue app, the ‘this’ keyword won’t be bound to the Vue instance and hence will throw errors. Therefore, it is strongly advised to use the standard function declaration instead.

Related questions

0 votes
Jan 9, 2020 in Vue.JS
0 votes
Jan 9, 2020 in Vue.JS
...