你会碰巧知道如何将用户设置为当前用户吗?我正在使用 vuefire 和 firebase。user.uid返回未定义。
<td v-if="(building['key'] && building['key'].child('ownerId')) == user.uid">
<p >{{building['.key']}} + {{user.uid}}</p>
</td>
这是我的其余代码:
import firebase,{ db, usersRef, buildingsRef } from '../firebase-config';
import { store } from '../store/store';
export default {
firebase() {
// from my understanding this just gives me a quick access to the Refs and a short nomenclature
return {
users: usersRef,
buildings: buildingsRef,
}
},
name: 'buildings',
data () {
return {
user: "",
building: {
name: '',
address: '',
comments: '',
ownerId: '',
},
}
},
我正在尝试通过 beforeCreate 钩子中的商店来做到这一点:
beforeCreate () {
this.$store.dispatch('setUser');
let user = this.$store.getters.getUser;
console.log(user); // this works!!!
this.$set(this.user, 'uid', user.uid )
}
},
如果相反,我将用户设置在创建钩子中,如下所示:
created () {
this.$store.dispatch('setUser');
let user = this.$store.getters.getUser;
console.log(user); // this works!!!
this.$set(this.user, 'uid', user.uid )
}
我收到此错误: