Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vue] vue-cli3插件有写过吗?怎么写一个代码生成插件? #540

Open
haizhilin2013 opened this issue Jul 2, 2019 · 2 comments
Labels
vue vue

Comments

@haizhilin2013
Copy link
Collaborator

[vue] vue-cli3插件有写过吗?怎么写一个代码生成插件?

@haizhilin2013 haizhilin2013 added the vue vue label Jul 2, 2019
@liuxiaoyang1
Copy link

MyPlugin.install = function (Vue, options) {
// 1. 添加全局方法或属性
Vue.myGlobalMethod = function () {
// 逻辑...
}

// 2. 添加全局资源
Vue.directive('my-directive', {
bind (el, binding, vnode, oldVnode) {
// 逻辑...
}
...
})

// 3. 注入组件选项
Vue.mixin({
created: function () {
// 逻辑...
}
...
})

// 4. 添加实例方法
Vue.prototype.$myMethod = function (methodOptions) {
// 逻辑...
}
}

@2860754963
Copy link

这不是vue全局方法嘛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vue vue
Projects
None yet
Development

No branches or pull requests

3 participants