7👍
✅
You could attach the firebase
to the Vue.prototype
:
import * as firebase from 'firebase'
let config = {
//
}
Vue.prototype.$firebase = firebase.initializeApp(config)
new Vue({
//
})
Then, use it to the components like this:
this.$firebase.database()
0👍
If you want to import it just once, you can simply do in your main.js
:
import * as firebase from 'firebase'
window.firebase = firebase
window
object is global for webpage and it’s normal practice to use it this way.
👤euvl
Source:stackexchange.com