赞
踩
Vue.js的插件应该有一个install方法,方法第一个参数是Vue的构造器,第二个是可选的选项对象
- const myPlugin={
- install(Vue,options){
- //1.添加全局方法或属性
- Vue.myMethod=function()
- //2.添加全局资源
- Vue.directive('myDirective',{})
- //3.注入组件选项
- Vue.mixin({
- created:function(){
-
- }
- })
- //4.添加实例方法
- Vue.prototype.$myMethod=function(){}
- }
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。