Vue.Js - Firebase functions cannot be used on components

后端 未结 1 1995
不知归路
不知归路 2021-01-16 08:51

I was using Vue Resource in posting data from my web app to the firebase. but then, I just found out that I need to use firebase integration to upload IMAGES in the firebase

1条回答
  •  北恋
    北恋 (楼主)
    2021-01-16 09:16

    You don't appear to be using VueFire, which I believe exposes firebase through a Vue prototype property as $firebase. However, you can do it yourself manually.

    import Vue from 'vue'
    import VueResource from 'vue-resource'
    import VueRouter from 'vue-router'
    import * as firebase from 'firebase'
    import App from './App.vue'
    import Routes from './routes'
    
    Vue.prototype.$firebase = firebase
    

    After that, firebase will be available in every Vue or component as this.$firebase.

    methods: {
        post: function(){
            this.$firebase.database().ref() ... etc ...
        }
    }
    

    0 讨论(0)
提交回复
热议问题