Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
未解析变量$firebaseRefs vue js_Firebase_Vue.js_Vuefire - Fatal编程技术网

未解析变量$firebaseRefs vue js

未解析变量$firebaseRefs vue js,firebase,vue.js,vuefire,Firebase,Vue.js,Vuefire,我有一个添加功能,可以将电影添加到firebase数据库 methods: { add() { this.$firebaseRefs.movies.push({ name: this.newItem.name, price: this.newItem.genre, rating: this.newItem.rating,

我有一个添加功能,可以将电影添加到firebase数据库

methods: {
            add() {
                this.$firebaseRefs.movies.push({
                    name: this.newItem.name,
                    price: this.newItem.genre,
                    rating: this.newItem.rating,
                    reviews: this.newItem.reviews,
                    cast: this.newItem.cast,

                });
                this.newItem.name = '';
                this.newItem.genre = '';
                this.newItem.rating = '';
                this.newItem.reviews= '';
                this.newItem.cast= '';
                this.$router.push('/dashboard')
            }
        }
    }
但是当我尝试将路由更改添加到 ?

我已经进口了

import { db } from '../db';
db.js

下面是main.js文件

main.js

import Vue from 'vue'
import App from './App.vue'
import router from "./routes/route.js";

import store from "./store";



Vue.config.productionTip = false;




new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')

正如vuefire中所述,您需要将vuefire作为Vue插件安装。因此,由于您使用的是实时数据库,因此需要如下调整
main.js
文件

import Vue from 'vue'
import App from './App.vue'
import router from "./routes/route.js";
import store from "./store";
import { rtdbPlugin } from 'vuefire'

Vue.use(rtdbPlugin)
Vue.config.productionTip = false;

new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')

请不要忘记安装最新版本的Vuefire,如下所示(请参阅文档):


您好,您需要分享更多详细信息,以便我们能够帮助您,特别是您安装了哪些以及如何安装,以及组件中的
imports
。我已编辑了问题确定,谢谢。你也可以分享你的
main.js
文件来看看你是如何导入插件的吗?@RenaudTarnec addedwhat-about-in-my-db.js?我应该也导入它吗?你写过你从“../db”导入{db}。应该没问题。如果您不确定,您可以分享Vue组件的全部内容。@Kadzokanne很高兴我能帮助您,并感谢您接受答案。如果你认为它有帮助,你也可以投赞成票。看见
import Vue from 'vue'
import App from './App.vue'
import router from "./routes/route.js";
import store from "./store";
import { rtdbPlugin } from 'vuefire'

Vue.use(rtdbPlugin)
Vue.config.productionTip = false;

new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')
npm install vuefire