I have these methods with similar functionality in different js files. I want to import these methods and add them to the vue methods I already have. The methods have also dependency so I have to pass parameters.
I have used the bind method to avoid calling the functions
I used the spread operator to list all the available functions to vue methods.
The intention is to divide vue file with more than 150 methods in it into separate files/modules and import the methods to that file/component
// functionsToBeImported.js
export default(param) {
method1 () {
console.log(param);
}
method2 () {
console.log(param);
}
return {
method1,
method2
}
}
import functionsToBeImported from './functionsToBeImported';
import anotherFunctionsToBeImported from './anotherFunctionsToBeImported';
export default {
methods: {
normalFunction(){},
...functionsToBeImported.bind(param),
...anotherFunctionsToBeImported.bind(param),
}
}