简体   繁体   English

如何解决“未捕获的TypeError:无法读取未定义的属性'Timestamp'”?

[英]How to fix “Uncaught TypeError: Cannot read property 'Timestamp' of undefined”?

Hi I'm new in web development and I'm trying to make a firebase app with the firestore database. 嗨,我是Web开发的新手,我正在尝试使用Firestore数据库制作一个Firebase应用程序。 I have a user registration form and in this form I need to get the date. 我有一个用户注册表格,需要填写该表格的日期。 For the date I used datepicker but I can't get the selected date and after transform it into firestore Timestamp. 对于日期,我使用了日期选择器,但无法获取所选日期,并将其转换为Firestore时间戳后。 I tried this but I don't know if something is correct: 我尝试了这个,但是我不知道是否正确:
Html form: HTML形式:

<input class="datepicker" type="text" id="subscriptionDeadline" placeholder="Subscription Deadline">

Javascript code: JavaScript代码:

  var currentDate = $(".subscriptionDeadline").datepicker("getDate");
  var timeStamp = new firebase.firestore.Timestamp.fromDate(currentDate);

I get this error : 我收到此错误:

Uncaught TypeError: Cannot read property 'Timestamp' of undefined 未捕获的TypeError:无法读取未定义的属性“ Timestamp”

Your error is Cannot read property 'Timestamp' of undefined . 您的错误是Cannot read property 'Timestamp' of undefined In the code, it is trying to access firebase.firestore.Timestamp . 在代码中,它正在尝试访问firebase.firestore.Timestamp

The error is saying that whatever you are trying to read the property Timestamp from, is undefined. 该错误表明您尝试从中读取属性Timestamp任何内容都是未定义的。 In your case it is firebase.firestore . 在您的情况下,它是firebase.firestore If you do a console.log(firebase.firestore) it will show undefined, which means you won't be able to access the Timestamp property or anything else. 如果执行console.log(firebase.firestore) ,它将显示未定义,这意味着您将无法访问Timestamp属性或其他任何属性。

It sounds like the problem is you haven't initialized firestore properly on your page. 听起来问题是您尚未在页面上正确初始化firestore。 Make sure you have followed these steps: https://cloud.google.com/firestore/docs/quickstart-mobile-web#set_up_your_development_environment 确保您已按照以下步骤操作: https : //cloud.google.com/firestore/docs/quickstart-mobile-web#set_up_your_development_environment

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获的TypeError:无法读取未定义的属性“时间戳” - Uncaught TypeError: Cannot read property 'timestamp' of undefined 如何修复未捕获的类型错误:无法读取未定义的属性“名称” - How to fix Uncaught TypeError: Cannot read property 'name' of undefined 如何修复Uncaught TypeError:无法读取undefined的属性&#39;settings&#39; - How to fix Uncaught TypeError: Cannot read property 'settings' of undefined 如何修复未捕获的类型错误:无法读取未定义的属性“原型”? - How to fix Uncaught TypeError: Cannot read property 'prototype' of undefined? 如何修复“未捕获的类型错误:无法读取未定义的属性‘替换’”错误? - How to fix "Uncaught TypeError: Cannot read property 'replace' of undefined" error? 如何修复&#39;Uncaught TypeError:无法读取未定义的属性&#39;length&#39; - How to fix 'Uncaught TypeError: Cannot read property 'length' of undefined' 如何修复Uncaught TypeError:无法读取Dygraphs中未定义的属性&#39;pageX&#39;? - How to fix Uncaught TypeError: Cannot read property 'pageX' of undefined in Dygraphs? 如何解决“未捕获的TypeError:无法读取未定义的属性&#39;number&#39;”? - How to fix “Uncaught TypeError: Cannot read property 'number' of undefined”? 如何修复“Uncaught TypeError: Cannot read property 'scrollHeight' of undefined”错误 - how to fix “Uncaught TypeError: Cannot read property 'scrollHeight' of undefined” error 未捕获的类型错误:无法读取未定义的属性“长度” - 无法修复/调试此问题 - Uncaught TypeError: Cannot read property 'length' of undefined - Cannot fix/debug this
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM