Javascript 将数据从firestore查询添加到数组对象,并将其映射到Picker react native
我的构造函数有:Javascript 将数据从firestore查询添加到数组对象,并将其映射到Picker react native,javascript,react-native,Javascript,React Native,我的构造函数有: this.ActiveDelegation={ 城市居民:[], 名称:“”, 到期日:'', } 这就是我从firestore获取数据到对象的方式,我假设它将名称添加到我创建的cittyArr[]中 getDelegationList=(querySnapshot)=>{ console.log(“快照”) querySnapshot.forEach((res)=>{ 常量{name,expiration}=res.data(); console.log('res is=>
this.ActiveDelegation={
城市居民:[],
名称:“”,
到期日:'',
}
这就是我从firestore获取数据到对象的方式,我假设它将名称添加到我创建的cittyArr[]
中
getDelegationList=(querySnapshot)=>{
console.log(“快照”)
querySnapshot.forEach((res)=>{
常量{name,expiration}=res.data();
console.log('res is=>',res.data())
this.ActiveDelegation.cityar.push({
密钥:res.id,
物件,
名称
到期
});
//返回
});
console.log('test2:',this.ActiveDelegation.cityar)
//log('test12312:',this.ActiveDelegation.cityar.city)
delegList=()=>{
return(this.ActiveDelegation.cityArr.map)((c,i)=>{
返回(
)
}
))
}
}
这是内部渲染:
<Item picker>
<Picker
mode="dropdown"
style={{ width: 20 }}
placeholder="choose destination"
placeholderStyle={{ color: "#bfc6ea" }}
placeholderIconColor="#007aff"
// selectedValue={this.state.Destination}
// onValueChange={this.onValueChangeG.bind(this)}
selectedValue={this.state.selectedDest}
onValueChange={ (value) => ( this.setState({selectedDest: value}) ) } >
{this.delegList}
{/*{cityItems}*/}
<Picker.Item label="select" value="" />
</Picker>
</Item>
(this.setState({selectedDest:value}))}>
{this.delegList}
{/*{cityItems}*/}
但我的采摘器里什么也没发生。。
有人能帮忙吗?我找到了解决办法。刚刚使用了picker作用域下渲染本身内部的贴图:
<Item picker>
<Picker
mode="dropdown"
style={{ width: 20 }}
placeholder="choose destination"
placeholderStyle={{ color: "#bfc6ea" }}
placeholderIconColor="#007aff"
selectedValue={this.state.Destination}
onValueChange={ (value) => ( this.setState({Destination: value}) ) } >
{/* onValueChange={this.onValueChangeG.bind(this)} >*/}
{/*<Picker.Item label="choose" value="" />*/}
{
this.state.destinationArr.map( (city, i) => {
return (
<Picker.Item label={city.name} value={city.name} key={i} />
)
})
}
</Picker>
</Item>
(this.setState({Destination:value}))}>
{/*onValueChange={this.onValueChangeG.bind(this)}>*/}
{/**/}
{
this.state.destinationArr.map((城市,i)=>{
返回(
)
})
}
修正了*你能在世博会上为这个做点点心吗?不知道怎么做,它也连接到了数据库。我可以添加整个文件在这里添加代码,然后将响应数据放入一个文件中。