J
J
Jora007772017-07-24 13:16:22
Vue.js
Jora00777, 2017-07-24 13:16:22

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

1 answer(s)
R
RaulDuke, 2017-07-24
@Jora00777

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 question

Ask a Question

731 491 924 answers to any question