render(){
var styleObj = {};
//如果props中制定了这张图片的位置信息,则使用
console.log(this.props.imgState.pos);
if(this.props.imgState.pos){
styleObj = this.props.imgState.pos;
}
return(
<figure className = 'img-figure' style = {styleObj}>
<img src = {this.props.imageData.imageURL} alt = {this.props.imageData.title}/>
<figcaption>
<h2 className = "img-title">{this.props.imageData.title}</h2>
</figcaption>
</figure>
)
}
请问这里值都输出了,为什么还是报错?
代码不全,没法判断。
说白了,imgState这个属性在某一时刻被设为了undefined。