[英]malformed calls from sizes
I need to push images to the array .However with this code ,I am getting the error 'malformed calls from sizes' 我需要将图像推送到数组。但是,使用此代码,我得到了错误“来自大小的格式错误的调用”
Here is the code . 这是代码。
constructor(props){
super(props);
this.state={
min_rating: 2 ,
max_rating: 5 ,
}
this.star_with_rating=<Image source={require('../assets/images/star_filled.png')}/>;
this. star_without_rating =<Image source={require('../assets/images/star_corner.png')}/>;
}
render(){
let arr=[];
for( let index=1;index<=10;index++){
arr.push(
<TouchableOpacity
activeOpacity={0.7}
key={index}
onPress={this.UpdateRating(index)}>
<Image
source={
index <= this.state.min_rating
? {uri:this.star_with_rating}
: {uri:this.star_without_rating}
}
/>
</TouchableOpacity>
)
}
However when i remove the uri portion inside Image component ,i get the error this is a reserved word . 但是,当我删除Image组件中的uri部分时,出现错误,这是保留字。
The problem you are setting as the uri as Image component instead of a string. 您正在将uri设置为Image组件而不是字符串的问题。 Which should be:
应该是:
this.star_with_rating = '../assets/images/star_filled.png';
so also I would call it start_with_rating_uri 所以我也称它为start_with_rating_uri
Check the documentation for more details. 查看文档以获取更多详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.