代码之家  ›  专栏  ›  技术社区  ›  Noitidart

获取父节点的节点句柄-类似于findNodeHandle

  •  0
  • Noitidart  · 技术社区  · 3 年前

    给定一个用 findNodeHandle ,是否可以获取父节点句柄?

    0 回复  |  直到 3 年前
        1
  •  1
  •   hong developer    3 年前

    下面是如何让孩子的父母的处理程序。

    import { findNodeHandle } from 'react-native';
    
    const UIManager = require('NativeModules').UIManager;
    
    const childHandler = findNodeHandle(this.refs.myElement);
    
    UIManager.measureLayoutRelativeToParent(
      childHandler, 
      (e) => {console.error(e)}, 
      (x, y, w, h) => {
        console.log('offset', x, y, w, h);
      });