React Native 获取屏幕宽度和高度 - Dimensions 组件
可以使用 Dimensions 组件来获取屏幕宽、高的值,具体代码如下:
import { Dimensions } from 'react-native';
const screenWidth = Dimensions.get('window').width;
const screenHeight = Dimensions.get('window').height;
以上代码中,Dimensions.get('window') 返回的是包含屏幕宽、高信息的对象,我们通过 .width 和 .height 来获取屏幕的宽、高。
原文地址: https://www.cveoy.top/t/topic/niri 著作权归作者所有。请勿转载和采集!