vue如何让自定义函数挂到全局


在main.js里进行全局注册
Vue.prototype.ajax = function (){}

在所有组件里可调用
this.ajax

// xxx.js 组件 exports.install = function (Vue, options) { Vue.prototype.ajax = function (){ alert('aaaaaaa'); }; };
// main.js 入口 import xxxx from './commons/xxxx' Vue.use(xxxx);
// ccc.js 子组件 this.ajax();








免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM