【发布时间】:2020-01-31 23:17:57
【问题描述】:
我正在尝试使用从 firebase 上的 get() 函数获得的信息设置一个变量,但我做不到。
export default {
name: "customer-navigation",
mixins: [navigationMixin],
components:{AppSnackBar, authModule,AuthForm},
data () {
return {
drawer: false,
items: [
{ title: this.$t('navigation.home'), icon: 'home', to: '/' },
{ title: this.$t('navigation.shop'), icon: 'shopping_basket', to:
'/shop' },
{ title: this.$t('navigation.cart'), icon: 'shopping_cart', to:
'/cart' },
{ title: this.$t('navigation.orders'), icon: 'view_headline', to:
'/orders' },
],
img_url: "" ,
nombreFire: "",
}
},
methods: {
getInfo(){
db.collection('users').doc(authModule.state.user.uid).get().then(function(doc) {
this.img_url = doc.data().img_url
})
}
}
}
Uncaught (in promise) TypeError: Cannot set property 'img_url' of undefined 在评估时,这是我得到的错误
【问题讨论】:
标签: javascript firebase vue.js google-cloud-firestore vuex