React native React Native:首次加载时未显示背景图像
对于首次加载,我的应用程序背景图像未在首次加载中显示 事实上,我使用的是地图,这些是集群的背景React native React Native:首次加载时未显示背景图像,react-native,react-native-maps,React Native,React Native Maps,对于首次加载,我的应用程序背景图像未在首次加载中显示 事实上,我使用的是地图,这些是集群的背景 componentWillMount(){ if (this.props.pointCount < 10) { this.cluster_image = require('../assets/cluster1_mobile.png') ; }else if (this.props.pointCount < 100) { this.cluste
componentWillMount(){
if (this.props.pointCount < 10) {
this.cluster_image = require('../assets/cluster1_mobile.png') ;
}else if (this.props.pointCount < 100) {
this.cluster_image = require('../assets/cluster2_mobile.png') ;
}else{
this.cluster_image = require('../assets/cluster3_mobile.png') ;
}
}
componentWillMount(){
如果(this.props.pointCount<10){
this.cluster_image=require('../assets/cluster1_mobile.png');
}否则如果(this.props.pointCount<100){
this.cluster_image=require('../assets/cluster2_mobile.png');
}否则{
this.cluster_image=require('../assets/cluster3_mobile.png');
}
}
在渲染中
<ImageBackground source={ this.cluster_image }>
<Text>
{this.props.pointCount}
</Text>
</ImageBackground>
{this.props.pointCount}
您可能需要在构造函数中设置
constructor(props){
super(props)
if (props.pointCount < 10) {
this.cluster_image = require('../assets/cluster1_mobile.png') ;
}else if (props.pointCount < 100) {
this.cluster_image = require('../assets/cluster2_mobile.png') ;
}else{
this.cluster_image = require('../assets/cluster3_mobile.png') ;
}
}
构造函数(道具){
超级(道具)
如果(props.pointCount<10){
this.cluster_image=require('../assets/cluster1_mobile.png');
}否则如果(props.pointCount<100){
this.cluster_image=require('../assets/cluster2_mobile.png');
}否则{
this.cluster_image=require('../assets/cluster3_mobile.png');
}
}