简体   繁体   English

获取未捕获错误:Reference.set 失败:尝试将数据保存到 Firebase 存储时,第一个参数在属性中包含未定义

[英]Getting Uncaught Error: Reference.set failed: First argument contains undefined in property when trying to save the data to firebase storage

I have an input field which on entering the input and clicking the save button, the data should be saved in the firebase storage.我有一个输入字段,在输入输入并单击保存按钮时,数据应保存在 firebase 存储中。 The code is as below,代码如下,

<div class="md-form">
  <input type="number" id="ip1" class="form-control">
  <label for="ip1">ip1</label>
</div>
<button type="button" id="ip1_btn" class="btn btn-dark-green">SAVE</button>

Below is what I am trying to achieve using js,以下是我尝试使用 js 实现的目标,

var rootRef = firebase.database().ref().child('demo-260b2');

    $('#ip1_btn').click(function(){
        rootRef.set({
            ip1:$('ip1').val()
            });
    })

While trying on the browser, I am getting the following error,在浏览器上尝试时,我收到以下错误,

Uncaught Error: Reference.set failed: First argument contains undefined in property 'demo-260b2.ip1'未捕获的错误:Reference.set 失败:第一个参数在属性“demo-260b2.ip1”中包含未定义

I am unable to figure out what's wrong in this.我无法弄清楚这有什么问题。 Any help would be very much helpful.任何帮助都会非常有帮助。

The error message is telling you that you provided a value of undefined somewhere in the object to set.错误消息告诉您,您在要设置的对象中某处提供了undefined值。 The only value you have here is from $('ip1').val() .您在此处拥有的唯一值来自$('ip1').val() I would conclude that value is actually undefined.我会得出结论,价值实际上是未定义的。 You should log/debug it to see for yourself.您应该记录/调试它以亲自查看。

My guess is that you meant to use this instead: $('#ip1').val() .我的猜测是您打算改用它: $('#ip1').val() Note the # in front of "ip1", which would call out the element with the HTML id "ip1".注意“ip1”前面的# ,它会调用HTML id 为“ip1”的元素。

暂无
暂无

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

相关问题 firebase.js:1 Uncaught (in promise) Error: Reference.set failed: 第一个参数包含未定义的属性 - firebase.js:1 Uncaught (in promise) Error: Reference.set failed: First argument contains undefined in property 未捕获的错误:Reference.set 失败:第一个参数在属性“Users.ji8A7TkSldfdvieDqGxko9eV3Jy1.gender”中包含未定义 - Uncaught Error: Reference.set failed: First argument contains undefined in property 'Users.ji8A7TkSldfdvieDqGxko9eV3Jy1.gender' firebase - Reference.set 失败:第一个参数在属性“users.undefined.profileImageUrl”中包含未定义 - firebase - Reference.set failed: First argument contains undefined in property 'users.undefined.profileImageUrl' Reference.set 失败:第一个参数在属性“users.undefined.profileImageUrl”中包含未定义 - Reference.set failed: First argument contains undefined in property 'users.undefined.profileImageUrl' 未处理的拒绝(错误):Reference.set 失败:第一个参数在属性“signup.test.Robots.props.history.location.state”中包含未定义 - Unhandled Rejection (Error): Reference.set failed: First argument contains undefined in property 'signup.test.Robots.props.history.location.state' v-on处理程序中的错误:“错误:Reference.set失败:第一个参数包含未定义” - Error in v-on handler: “Error: Reference.set failed: First argument contains undefined” ERROR 错误:Reference.set 失败:第一个参数在属性中包含无效的键 ($key) - ERROR Error: Reference.set failed: First argument contains an invalid key ($key) in property 错误:Firebase.set失败:第一个参数在属性“ achv_img”中包含未定义 - Error: Firebase.set failed: First argument contains undefined in property 'achv_img' Firebase 实时数据库 JS 错误:Reference.set 失败 - Firebase Realtime Database JS Error : Reference.set failed Reference.push 失败:第一个参数在属性中包含未定义 - Reference.push failed: first argument contains undefined in property
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM