Unable to return value from Vuejs method and firestore

前端 未结 2 341
挽巷
挽巷 2021-01-17 05:38

i want to return the value from the firestore OnSnapshot function so that i can retrieve the url of user image. I am using vuejs and firestore. And i have activeUserIm

2条回答
  •  不思量自难忘°
    2021-01-17 06:05

    return statement should be inside of the firestore callback just like below

    activeUserImg: function () {
               const u = firebase.auth().currentUser;
    firebase.firestore().collection('Colleges').doc(u.uid).onSnapshot(function(doc) {
    
         var img_arr=[];
        this.img_arr.push(doc.data())
        this.img= doc.data().logo
        return this.img || this.$store.state.AppActiveUser.img;
    });
    
    
        }
    

提交回复
热议问题