我在 /buildings.vue 组件的顶部导入了一个firebase:
...
import buildingsadd, { buildingsRef } from './buildingsadd.vue';
export default {
firebase() {
return {
buildings: buildingsRef
}
},
components: {
buildingsadd
},
name: 'buildings',
...
在 /buildingsadd.vue 组件上,我正在定义firebase ref的新路径,如下所示:
...
import firebase from '../firebase-config';
import { db } from '../firebase-config';
export default {
firebase() {
return {
buildings: buildingsRef,
users: usersRef,
}
},
name: 'buildingsadd',
data () {
return {
newBuilding: {
name: '',
}
}
},
methods: {
addBuilding: function () {
let userId = firebase.auth().currentUser.uid;
let buildingsRef = db.ref('buildings/'+userId);
}
...
但我收到了这个错误:
对此的回答也将解决我的特殊问题:
答案 0 :(得分:0)
您没有导出buildingsRef
。将其导出如下。
<强> buildingsadd.vue 强>:
import firebase from '../firebase-config';
import { db } from '../firebase-config';
let userId = firebase.auth().currentUser.uid; // added
export let buildingsRef = db.ref('buildings/'+userId); // added
export default {
// ... (all the same)
methods: {
addBuilding: function () {
// removed lines here
}
...