离子含量中的离子反应堆火力对象

时间:2020-08-12 14:04:21

标签: javascript json reactjs firebase ionic-framework

我是打字稿和Firebase的新手。我如何循环使用firebase对象,因为无法使用map函数使用它。如果可能的话,我想将其转换为数组以便循环。这是我尝试过的:

const [doctors, setDoctor] = React.useState([]);


  useIonViewDidEnter(()=>{
    console.log('Enter')
    firebase.database().ref('users').orderByChild('type').equalTo('doctor').on('value',(snapshot)=>{
          // console.log(snapshot.val())
          setDoctor(snapshot.val())
          // event.detail.complete()
        })
  })

我的返回HTML看起来像

        <IonList>
        {doctors.map(elem => {
            return(
              <IonItem key={elem['uid']} onClick={getDoctors}>
              <IonLabel>
                <IonText className="font-weight: bold;">
                <h3>{elem['name']}</h3>
                </IonText>
                <h4>{elem['speciality']}</h4>
                <h4>{elem['email']}</h4>
              </IonLabel>
              <br></br>
            </IonItem> 
            )
          })}
        </IonList>

我的Firebase数据样本 enter image description here

此外,我无法在vue js中使用v-for之类的内容来直接在模板中进行呈现。如果有人知道我该怎么办,请随时发表评论。预先感谢!

0 个答案:

没有答案