Answer the question
In order to leave comments, you need to log in
How to make a global method in vuejs?
Hello.
How can I make a method in vuejs that I can call from any component?
It's just that I use the same method in several components, and in order not to write it for each, can I somehow place it in a separate file?
And what is the best way to use it?
methods: {
getAllCategories() {
axios.get('/api/categories')
.then(res => this.categories = res.data)
.catch(err => console.log('Error'));
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question