Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/478.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
Javascript 如何为firebase配置nativescript vue应用程序?_Javascript_Android_Vue.js_Firebase Realtime Database_Nativescript Vue - Fatal编程技术网

Javascript 如何为firebase配置nativescript vue应用程序?

Javascript 如何为firebase配置nativescript vue应用程序?,javascript,android,vue.js,firebase-realtime-database,nativescript-vue,Javascript,Android,Vue.js,Firebase Realtime Database,Nativescript Vue,我用nativescript vue制作了我的第一个应用程序,并想知道如何将firebase连接到我的应用程序。我的想法是从实时firebase数据库中添加和读取数据 我按照一些指南做了以下工作: 1) 我用命令安装了firebase:“tns plugin add nativescript plugin firebase” 2) 然后,我从firebase项目中配置并下载了google-services.json文件 这是main.js文件的内容 从“nativescript Vue”导入Vu

我用nativescript vue制作了我的第一个应用程序,并想知道如何将firebase连接到我的应用程序。我的想法是从实时firebase数据库中添加和读取数据

我按照一些指南做了以下工作:
1) 我用命令安装了firebase:“tns plugin add nativescript plugin firebase”
2) 然后,我从firebase项目中配置并下载了google-services.json文件

这是main.js文件的内容

从“nativescript Vue”导入Vue
从“./components/App”导入应用程序
从“nativescript插件firebase”导入firebase
从“nativescript vue devtools”导入VueDevtools
如果(TNS_ENV!=“生产”){
Vue.use(VueDevtools)
}
//在生成时,当--env.production*未*设置时打印Vue日志
Vue.config.silent=(TNS_ENV==='production')
火基
.init()
。然后(()=>console.log('Firebase initialized!'))
.catch(error=>console.log(`error:${error}`));
新Vue({
渲染:h=>h('帧',[h(应用)])
}).$start()
这是App.vue文件的内容

<template>
    <Page>
        <ActionBar title="App demo"/>
        <GridLayout columns="*" rows="*">
            <Label class="message" :text="msg" col="0" row="0"/>
        </GridLayout>

        <button @tap="test()">Push</button>
    </Page>
</template>

<script>
import firebase from 'nativescript-plugin-firebase';

  export default {
    data() {
      return {
        msg: 'Hello World!'
      }
    },
    methods: {
      test(){
        alert("click");
        //FIREBASE PUSH 
    }
    }
  }
</script>

<style scoped>
    ActionBar {
        background-color: #1F2327;
        color: #ffffff;
    }

    .message {
        vertical-align: center;
        text-align: center;
        font-size: 20;
        color: #333333;
    }
</style>
 firebase.push(
      '/users',
      {
        'first': 'Eddy',
        'last': 'Verbruggen',
        'birthYear': 1977,
        'isMale': true,
        'address': {
          'street': 'foostreet',
          'number': 123
        }
      }
  ).then(
      function (result) {
        console.log("created key: " + result.key);
      }
  );