0
我有一个onLayout在图像中的问题:onLayout与图像 - 反应本机
我有一个函数来显示维度。
measureView(event) {
console.log(event.nativeEvent.layout.width);
console.log(event.nativeEvent.layout.height);
}
这工作,并显示我的TouchableWithoutFeedback
<TouchableWithoutFeedback
style={styles.touchableWithoutFeedback}
onLayout={(event) => this.measureView(event)}>
<Image style={styles.image}
source={require("./../assets/images/photo_1.jpg")}/>
</TouchableWithoutFeedback>
但随着onLayout在图像尺寸,我什么也没得到,只是不确定。
<TouchableWithoutFeedback
style={styles.touchableWithoutFeedback}>
<Image style={styles.image}
source={require("./../assets/images/photo_1.jpg")}
onLayout={(event) => this.measureView(event)}/>
</TouchableWithoutFeedback>
你有想法为什么?
谢谢!
Endeed,我完全改变了我的网络图像代码。但你的回答是对的! – Wandrille