1.在main.js里面写:
//全局挂在公共函数
import * as common from './util/common' //在此引用的是common.js
// 公用封装
Vue.prototype.$common = common
//=============================
2.common.js的内容:
export function alt() {
alert(2);
}
3.在需要用到的组件里调用,调用方法如下:
this.$common.alt();
或者
this..alt();