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