React native 如何找到两个元素之间的距离? import React,{useState,useffect,useRef}来自'React'; 从“react native”导入{样式表、视图、文本、动画、UIManager、findNodeHandle、PanResponder}; const TestScreen=props=>{ const myPosition=useRef(); const enemyPosition=useRef(); 返回(

React native 如何找到两个元素之间的距离? import React,{useState,useffect,useRef}来自'React'; 从“react native”导入{样式表、视图、文本、动画、UIManager、findNodeHandle、PanResponder}; const TestScreen=props=>{ const myPosition=useRef(); const enemyPosition=useRef(); 返回(,react-native,React Native,请使用尺寸 import { Dimensions } from 'react-native'; 然后得到窗口宽度 const windowWidth = Dimensions.get('window').width; 根据您的情况,它应该是windowWidth-40 =窗宽-20(左侧框)-20(右侧框)

请使用尺寸

 import { Dimensions } from 'react-native';

然后得到窗口宽度

const windowWidth = Dimensions.get('window').width;
根据您的情况,它应该是windowWidth-40

=窗宽-20(左侧框)-20(右侧框)