-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
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
plugin interface spec #88
Comments
I have a few questions about the plugin interface!
Idea 1: a configuration function// my-plugin.js
module.exports = function(config) {
return function(Vue) {
};
}; // my-app.js
var myPlugin = require('my-plugin');
Vue.use(myPlugin({ foo: 'bar' })); The issue with that solution is that it disables the usage of the shorthand: // my-app.js
Vue.use('my-plugin'); // Won’t work, only the configure function is called Idea 2: add a
|
Thanks for the suggestions Pierre! The original issue is a bit out of date - require is no longer passed in as an argument. I have edited it.
Vue.use(plugin, { foo: 'bar' })
// or
Vue.use('my-plugin', { foo: 'bar' }) We just need to change Vue.use = function (plugin, options) {
// if plugin is string require it
plugin.install(Vue, options)
} Inside plugins:
Plugins that don't need options can simply ignore the options argument. I want plugins to be implemented without having to require Vue at all, so that we can easily mock Vue and test the plugin. |
Thanks for your answers! |
Verbose version
Shorthand equivalent
Inside plugin...
The
use
function...The text was updated successfully, but these errors were encountered: