如果你需要让一个工具函数在每个组件可用,可以把方法挂载到 Vue.prototype上。
在main.js中:
Vue.prototype.method = function () {}
组件中调用:
this.method()