Answer the question
In order to leave comments, you need to log in
How to properly move a function into a vue.js module?
Hello, I have an addStatistics method that works in multiple components. In order not to duplicate the code, I decided to move this method to the functions.js file and put it in the root, and import this file into the components and call it.
Here is the functions.js file code
module.exports = {
addStatistics: function(link, action) {
...
this.$ls.get('key');
...
}
Answer the question
In order to leave comments, you need to log in
Use mixins https://ru.vuejs.org/v2/guide/mixins.html. In your case, this is the most correct and simple solution.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question