How to introduce js? into vue globally

common.js will have many functions that I define myself, such as:

export function a(){
    //
}
export function b(){
    //
}
export function c(){
    //
}

I will quote him in ad.vue:

import {a} from "@/assets/js/common.js"

I will quote him in role.vue:

import {b} from "@/assets/js/common.js"

N pages need to use functions in common.js. It"s troublesome for me to quote them one by one. Is there a good solution?

< hr >

I tried to introduce common in main.js

import "@/assets/js/common.js"

but this method does not work, it will prompt XX is not defined


me, too, not even on App.vue ~ ~ can only be written in


webpack. There is a global keyword that defines global properties.
the property method defined by this keyword can be used directly in the global file. I have tried the method adopted by


, which is the way of export multiple functions, but the way of using Vue.prototype.$a=a does not seem to work. You will not find $a


can be attached to the Vue prototype.
such as: Vue.prototype.$a=a
use: this.$a

Menu