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

Suggestion about using a plugin in a single project contains multi versions of vue #5970

Closed
LancerComet opened this issue Jun 26, 2017 · 0 comments

Comments

@LancerComet
Copy link

What problem does this feature solve?

A project may contains different versions of Vue, but the designing of plugin system is not designed for that.

The plugin would be available for only one vue library, no matter how many vue libs you require.

// My Plugin.
export default {
  install (Vue, options) {
    Vue.doSomething = function () {...}
  }
}
// Module 01 in my project.
import Vue from 'vue'  // Maybe vue 2.2
import MyPlugin from 'my-plugin'

Vue.use(MyPlugin)
Vue.doSomething()  // Yeah.
// Module 02 in my project.
import Vue from 'vue'  // Maybe vue 2.3.
import My Plugin from 'my-plugin'

Vue.use(MyPlugin)  // It doesn't work because "installed" has already been set to "true".
Vue.doSomething()  // Boom! Undefined!

What does the proposed API look like?

So this is what I'm doing:

// My Plugin.
export default function () {
  return {
    install (Vue, options) {
       Vue.doSomething = function () {...}
    }
  }
}
// Module 01 and 02 in my project.
import Vue from 'vue'
import MyPlugin from 'my-plugin'

Vue.use(MyPlugin())
Vue doSomething()  // Yeah!

Same as "data" properity.

Hope can be improved.😀

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

No branches or pull requests

2 participants