A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/vuejs/vue/issues/5970 below:

Suggestion about using a plugin in a single project contains multi versions of vue · Issue #5970 · vuejs/vue · GitHub

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.😀

Pickcle, KarlBao and zzx8865


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4