具有phonegap和firebase的移动应用程序

Noob程序员

我正在使用phonegap桌面应用程序(当我在桌面应用程序中单击“创建文件”时,文件会自动生成。)与此项目一起使用atom编辑器和firebase。总结我的项目,这只是某种调查,因此用户将不得不填写一些表格。

我无法将表单详细信息上载到Firebase。我确定Firebase已正确连接,因为我能够从Firebase检索数据并显示在控制台中。但是它无法将表单数据存储到其中。

这是我的html页面

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <script type="text/javascript" src="cordova.js"></script>
    <link rel="stylesheet" type="text/css" href="style.css">
    <title>AMT Survey</title>
</head>
<body>
<a href="index.html"><img src="img/back.png"  style="width:8%;"></a><br>
<form id="amtForm">
<b style="font-size: 27px;">AMT <p></b>
<b class=fs>Screen by: </b><br><input type="text" name="screenby" id="screenby"><br>
<b class=fs>Name of client:</b> <br><input type="text" name="client" id="client"><br>
<b class=fs>Date: </b><br><input type="date" name="date" id="date"><p>
  <input type="submit" class="button" value="Submit">
  <!--<button (click)="postData(name)">submit</button>-->
  </form>

  <script src="https://www.gstatic.com/firebasejs/4.6.2/firebase.js"></script>
   <script scr="main.js"></script>
   </body>
   </html>

这是我的js文件

 // Initialize Firebase
 (function() {
  const config = {
  apiKey: "",
  authDomain: "",
  databaseURL: "",
  projectId: "",
  storageBucket: "",
  messagingSenderId: ""
  };
  firebase.initializeApp(config);
   }());

  //reference messages collection
  var nameRef = firebase.database().reference('name');

   // listen for form submit
   document.getElementById('amtForm').addEventListener('submit',submitForm);


   function submitForm(e){
   e.preventDefault();

   var name = getInputVal('name');
   var client = getInputVal('client');
   var date = getInputVal('date');

   saveMessage(name,client,date);
   }

   function getInputVal(id){
   return document.getElementById(id).value;
    }

   function saveMessage(name,client,date){
   var newMessageRef = nameRef.push();
   newMessageRef.set({
   name:name,
   client:client,
   date:date
   });
   }
   /*
   postData(name){
   firebase.database().ref().push({name:name});
   }
   */

这些代码来自youtube视频教程,他似乎没有遇到像我一样的错误。这是视频https://www.youtube.com/watch?v=PP4Tr0l08NE

我的代码有什么问题吗?还是我的设置错误?还是其他原因?

希望此sreenshot帮助提供屏幕截图,下划线是我在文本框中键入的值。
这表明已读取数据,但是以某种方式它不会进入
firebase FYI:cornova.js脚本不会影响连接。这不是一个错误的错误

在此处输入图片说明

用户名

您是否将读写权限设置为true?

还要更改此内容://参考消息集合var nameRef = firebase.database()。reference('name');

若要://参考消息集合var nameRef = firebase.database()。ref('name');

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在移动浏览器或PhoneGap应用程序之间检测

具有Identity和EF的3层应用程序

带有Bootstrap 3,jQuery和phonegap的移动应用程序,可以吗?

混合移动应用程序:PhoneGap和Cordova之间的区别

将相同的Firebase应用程序与Web和移动应用程序一起使用

如何使Google Apps Scripts Web应用程序具有响应性并且对移动设备友好?

具有TabBar和SlideMenu的iOS应用程序

如何从网站上检测用户是否具有移动应用程序并打开该应用程序

如何将具有Angular v7的Web应用程序迁移到移动NativeScript应用程序

具有QSplitter和QMainWindow的应用程序QMdiarea

Firebase配额的移动应用程序数

是否有可能具有不同的Web应用程序以及与Firebase连接的移动设备是否不同?

PhoneGap(网络移动应用程序)-在页面之间传输数据

ClojureScript和移动应用程序的大小

使用phonegap的移动应用程序流星

PhoneGap JQuery移动应用程序-溢出问题

将现有的GWT项目迁移到GWT移动应用程序和PhoneGap

具有60秒超时的Phonegap应用程序缓存

混合或本机移动应用程序开发(phonegap或eclipse)

有没有一种方法可以从build.phonegap.com构建流星移动应用程序?

对于混合移动应用程序,FB应用程序应具有哪些“站点URL”?

Qt桌面和移动应用程序

Phonegap-Windows移动应用程序模拟器

使用Azure App Service的Web应用程序和移动客户端具有相同的业务逻辑

Phonegap Ionic应用程序无法在具有Rest API的设备上运行

使用 Phonegap/Cordova JS 应用程序和 MS ADAL JS。如何在真实移动设备中重定向 URI?

构建错误。在具有多个目标和 NotificationServiceExtensions 的 Xcode iOS 应用程序中安装 Firebase

如何选择技术来创建具有 3D 对象的移动应用程序?

具有 Firebase 连接的 Android 应用程序