0

我在/buildings.vue组件的顶部导入了一个火力基地:

...
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);
    }
...

但是我收到了这个错误:

在此处输入图像描述 有任何想法吗?

对此的答案也将解决我的特定问题:

4

1 回答 1

0

您不是在导出buildingsRef. 像下面这样导出它。

建筑物添加.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
    }
...
于 2018-04-10T16:09:28.560 回答