react native获取组件高度,宽 度等

时间:2023-03-08 15:40:41
react native获取组件高度,宽 度等

import React,{Component} from 'react'
import {
View,
Text,
Image,
StyleSheet,
TouchableHighlight,
TouchableOpacity,
ScrollView,
findNodeHandle,
UIManager,
} from 'react-native'

export  default  class  GoodsSelectAssembly extends Component {
getHeight() {
        const handle = findNodeHandle(ScrollFun);
        return new Promise((resolve) => {
            UIManager.measure(handle, (x, y, width, height, pageX, pageY) => {
                console.log(x, y, width, height, pageX, pageY)
            });
        });
    }
}
render(){
return(
   <ScrollView
                    style={{backgroundColor:'#fff'}}
                    ref={(ScrollView)=>{ScrollFun=ScrollView}}
                >
</ScrollView>
)
}