我写了一个if if null
见下文,它工作正常。React Native - If else null not working
{this.state.tomorrow.length > 0 ?
<ListItem itemDivider style={{backgroundColor: 'crimson'}}>
<Text style={{color: 'white'}}>Tomorrow</Text>
</ListItem> : null
}
然后我在另一页上写了这个,它不工作,我做错了什么?
<Grid>
<Row style={{paddingBottom:10}}>
<Col>
<Text>Location:</Text>
</Col>
<Col>
<Text>{ this.state.appointment.location }</Text>
</Col>
</Row>
{this.state.appointment.location_bool ? <Text>Hello</Text> : null }
</Grid>
错误我得到的是:
无法读取空的特性 '类型'
感谢
第二部分是没有这条线的工作:'{此.state.appointment.location_bool?你好 :null}'??我认为问题在别的地方,你在任何地方使用类型? –
@MayankShukla是的,没有这条线就可以正常工作 - 不会在任何地方使用类型。 –
通过任何API调用从服务器获取'约会'数据? –