1main.js中定义
定义Vue.prototype.fn名字=function(){}
使用 this.fn名字()
2自定义.js中定义
a)export.install=function(Vue,options){
Vue.prototype.fnName=function(){}
}
b)import ownjs from 自定义.js
Vue.use(ownjs )
c)组件中使用this.fnName();
1main.js中定义
定义Vue.prototype.fn名字=function(){}
使用 this.fn名字()
2自定义.js中定义
a)export.install=function(Vue,options){
Vue.prototype.fnName=function(){}
}
b)import ownjs from 自定义.js
Vue.use(ownjs )
c)组件中使用this.fnName();
本文标题:vue自定义全局函数
本文链接:https://www.haomeiwen.com/subject/prvjmctx.html
网友评论