test('use', () => {
const PluginA: Plugin = app => app.provide('foo', 1)
const PluginB: Plugin = {
- install: app => app.provide('bar', 2)
+ install: (app, arg1, arg2) => app.provide('bar', arg1 + arg2)
}
const PluginC: any = undefined
const app = createApp()
app.use(PluginA)
- app.use(PluginB)
+ app.use(PluginB, 1, 1)
const Root = {
setup() {
export interface App<HostElement = any> {
config: AppConfig
- use(plugin: Plugin, options?: any): this
+ use(plugin: Plugin, ...options: any[]): this
mixin(mixin: ComponentOptions): this
component(name: string): Component | undefined
component(name: string, component: Component): this
reload?: () => void // HMR only
}
-type PluginInstallFunction = (app: App) => any
+type PluginInstallFunction = (app: App, ...options: any[]) => any
export type Plugin =
| PluginInstallFunction
}
},
- use(plugin: Plugin) {
+ use(plugin: Plugin, ...options: any[]) {
if (installedPlugins.has(plugin)) {
__DEV__ && warn(`Plugin has already been applied to target app.`)
} else if (isFunction(plugin)) {
installedPlugins.add(plugin)
- plugin(app)
+ plugin(app, ...options)
} else if (plugin && isFunction(plugin.install)) {
installedPlugins.add(plugin)
- plugin.install(app)
+ plugin.install(app, ...options)
} else if (__DEV__) {
warn(
`A plugin must either be a function or an object with an "install" ` +