我如何从名称值中收集所有数据,以便可以使用?

时间:2019-11-11 18:49:04

标签: javascript firebase firebase-realtime-database

  let inpPas = document.querySelector('#inpPas');
  let btnGo = document.querySelector('#btnGo');


  const db = firebase.database();
  let ref = db.ref('xVerdi');


  let rootRef = firebase.database().ref().child('xVerdi');
  rootRef.on('child_added', snap => {

    let name = snap.child('name').val();

    btnGo.onclick = goPassword;

    function goPassword(){

        if (inpPas.value == name) {
          alert("yeyeye")
        }

      console.log("her " + name)
    }

    console.log(name)
  })

我想使用此名称:值存储的所有数据,但我只能使用最讨厌的数据。有什么建议么?

1 个答案:

答案 0 :(得分:1)

执行以下操作:

let nameList = [];
let rootRef = firebase.database().ref().child('xVerdi');
  rootRef.on('child_added', snap => {
let name = snap.child('name').val();
nameList.push(name);