Skip to content

Commit 8dcf8ef

Browse files
committed
fix(rtdb): fix global vue 2
1 parent c529d88 commit 8dcf8ef

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/vuefire/rtdb.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
toRef,
1515
getCurrentInstance,
1616
onBeforeUnmount,
17+
isVue3,
1718
} from 'vue-demi'
1819

1920
/**
@@ -171,7 +172,11 @@ export const rtdbPlugin = function rtdbPlugin(
171172
const globalOptions = Object.assign({}, defaultOptions, pluginOptions)
172173
const { bindName, unbindName } = globalOptions
173174

174-
app.config.globalProperties[unbindName] = function rtdbUnbind(
175+
const GlobalTarget = isVue3
176+
? app.config.globalProperties
177+
: (app as any).prototype
178+
179+
GlobalTarget[unbindName] = function rtdbUnbind(
175180
key: string,
176181
reset?: RTDBOptions['reset']
177182
) {
@@ -180,7 +185,7 @@ export const rtdbPlugin = function rtdbPlugin(
180185
}
181186

182187
// add $rtdbBind and $rtdbUnbind methods
183-
app.config.globalProperties[bindName] = function rtdbBind(
188+
GlobalTarget[bindName] = function rtdbBind(
184189
this: ComponentPublicInstance,
185190
key: string,
186191
source: database.Reference | database.Query,

0 commit comments

Comments
 (0)