0
在我的渲染函數中,我提出了一個請求,所以加載時會顯示'loading'。接收到數據後,我調用'setState'使DOM重新渲染。我想展示模態,但模態不存在。我怎麼了?React-Native Modal在Dom渲染時不顯示
render: function() {
if (!this.props.data) {
return (<View style={{flex:1}}>
<Text>loading</Text>
</View>);
}
return (
<View style={{flex:1, width:screenWidth}}>
<Modal
visible={true}
transparent={true}
onRequestClose={()=>{
}}
onShow={()=>{
}}>
<View
style={{flex:1,justifyContent:'center',alignItems:'center',backgroundColor:'rgba(0, 0, 0, 0.3)'}}>
<View style={{height:200,width:275,backgroundColor:'white'}}>
<Button title='confirm' onPress={()=>{}}/>
<Button title='cancel' onPress={()=>{}}/>
</View>
</View>
</Modal>
</View>
);
}
@Eric你有沒有修好? –
我收到了一個錯誤,'意外的令牌'。也許'?:'不能在返回函數中使用? – Eric
你可以請顯示該代碼嗎? –