I've put together a module called greetings.js, structured like this:
function greetings() {
this.hello = function() {
return 'hello!';
}
this.goodbye = function() {
return 'goodbye!';
}
}
module.exports = greetings;
Next, I brought it into main.js within the VUE.JS framework as shown below:
import greetings from './assets/js/greetings';
Vue.use(greetings);
Now, when trying to utilize it in my components, an error occurs:
mounted() {
this.greetings.hello();
}
ERROR: Error in mounted hook: "TypeError: Cannot read property 'hello' of undefined"
Any tips on how to resolve this issue and successfully use my greetings module? Appreciate any assistance!