javascript - 离子内容中的离子反应循环火力对象
问题描述
我是打字稿和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>
我也不能使用像v-for
vue js 这样的东西来直接在模板中渲染。如果有人知道我该怎么做,请随时发表评论。提前致谢!!
解决方案
推荐阅读
- jsonata - 查找包含文本的字段并将其替换为另一个文本
- python-3.x - 如何根据扩展名组织文件系统
- cluster-computing - 如何使用 Infinispan Server 10.0.0 设置集群
- javascript - 选择形式反应
- python - Adaptive modelling using GEKKO sysid
- r - 在 R 中查找掷骰的条件概率
- raku - 是否可以解析一个字符串,就好像它在 Raku 中被 << 和 >> 包围?
- machine-learning - 如何为机器人代码构建状态/动作的 Q 表?
- android - 如何在 Android Studio 上构建一个 apk
- neural-network - 使用 Gekko 的大脑模块,我如何确定使用多少层和什么类型的层来解决深度学习问题?