1.base.js:
// base.js
exports.install = function(Vue, options) {
Vue.prototype.text1 = function() {
console.log('执行成功1');
};
Vue.prototype.text2 = function() {
console.log('执行成功2');
};
};
2.main.js:
import Vue from 'vue'; // vue要在引文件之前
import base from './base.js'; // 引用文件
Vue.use(base); //将全局函数当做插件来进行注册
3:组件引用:
this.text1();
this.text2();