插件
util.js
export default{
install(Vue,options)
{
Vue.prototype.getData = function () {
console.log('我是插件中的方法');
}
}
}main.js 引入 并且全局注册
import util from './util' Vue.use(util);
其他组件中使用
this.getData();
参考:
https://cn.vuejs.org/v2/guide/plugins.html#使用插件
https://www.zhihu.com/question/40508884?sort=created
声明:本站所有文章和图片,如无特殊说明,均为原创发布,转载请注明出处。