reactNative 获取组件高、宽、位置等信息
阅读原文时间:2023年07月12日阅读:1

import {findNodeHandle, UIManager} from 'react-native'

layout(ref) {
const handle = findNodeHandle(ref);

return new Promise((resolve) => {  
  UIManager.measure(handle, (x, y, width, height, pageX, pageY) => {  
    resolve({  
      x,  
      y,  
      width,  
      height,  
      pageX,  
      pageY  
    });  
  });  
});  

}