I have a class and method that I need to import globally, so that I could avoid importing it again in each Vue file. I usually import my own class and method in each Vue file like this:
// in myFunc.js
export const fn = {
myFunc: function(param) { alert(param) }
}
// then I use it like this
import {fn} from '@/assets/js/myFunc.js';
fn.myFunc('Lorem ipsum');
In main.js
, I tried the following code, which does not work:
import {fn} from '@/assets/js/myFunc.js';
Vue.mixin({
components: { fn },
})
How do I import the class/methods globally?