TypeError:ref.key不是一个函数 [英] TypeError: ref.key is not a function

查看:173
本文介绍了TypeError:ref.key不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AngularJS: v1.5.11
Firebase: v3.6.9
Angularfire: v2.3.0



我想获得钥匙。创建JSON对象后,我的代码:

 })。then(function(ref){
var id = ref .key();
console.log(添加用户ID:+ id);

值被插入到firebase数据库中,但得到这个错误,没有任何内容显示在控制台日志中。



我猜这个键的语法是随着这些版本,我不知道什么 ref.key()是真正用到的,是否需要设置一些主键?



解决方案

Reference.key()曾经是Firebase JavaScript SDK 2.x中的一个函数,但现在是只读属性,所以你应该使用 ref.key



升级代码时需要了解的更多内容在针对网络开发人员的Firebase迁移指南中: https://firebase.google.com/support / guides / firebase-web

AngularJS: v1.5.11 Firebase: v3.6.9 Angularfire: v2.3.0

I want to get the key. After creating the JSON object my code :

  }).then(function(ref){
          var id = ref.key();
          console.log("Added User with ID: "+id);

The value is inserted in the firebase DB but getting this error and nothing is shown in the console log.

I guess the syntax to get the key is changed with these versions. I don't know what the ref.key() is used for really. Is it required as to set some primary key?

解决方案

Reference.key() used to be a function in Firebase JavaScript SDK 2.x. But is is now a read-only property, so you should use ref.key.

This and many more things to be aware of when upgrading your code are covered in the Firebase migration guide for web developers: https://firebase.google.com/support/guides/firebase-web

这篇关于TypeError:ref.key不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆