Skip to content

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

Open
@haizhilin2013

Description

@haizhilin2013
Collaborator

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

Activity

liuxiaoyang1

liuxiaoyang1 commented on Nov 19, 2019

@liuxiaoyang1

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

2860754963 commented on Jan 30, 2023

@2860754963

这不是vue全局方法嘛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @haizhilin2013@liuxiaoyang1@2860754963

        Issue actions

          [vue] vue-cli3插件有写过吗?怎么写一个代码生成插件? · Issue #540 · haizlin/fe-interview