[Vuejs]-Vuejs – How to call the mounted function of main.js from another Js file

2👍

You are exporting an object in commonValidation.js file.
An object cannot be invoked like a function.

I think your intent is to use a mixin. A mixin is nothing but an object that contains reusable component options as its properties.

So just register the mixin on the root component in your main.js file:

//main.js
import Vue from 'vue'
import BootstrapVue from 'bootstrap-vue'
import App from './App'
import router from './router'
import VeeValidate from 'vee-validate';
import commonValidation from './commonValidation'

Vue.use(VeeValidate);
Vue.use(BootstrapVue);

new Vue({
    el: '#app',
    router,
    template: '<App/>',
    components: {
        App
    },
    mixins : [commonValidation]
}

Leave a comment