Answer the question
In order to leave comments, you need to log in
Where is the best place to write your functions in Vue.js?
Hello.
I started learning Vue.js and the question arose, where is it better to write my functions necessary for the application to work?
Live example:
There is a certain function - foo, which looks for values of get parameters in the url, it is necessary to call it when the page is updated.
The function is needed in one component.
So where is the best place to put this feature?
Answer the question
In order to leave comments, you need to log in
If a function is used once and is an integral part of a component, then obviously it should be a method of the component.
If you plan to use this method in other components, then you need to look at the context, i.e. what is this function and where does it fit logically. Perhaps it should be moved to a separate component, perhaps to a helper library, or maybe to filters.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question