问题描述:
开发中想要占满屏幕,但是无法兼容所有屏幕,在有些分辨率下可以,有些不行
解决方案:
1、在utils中创建screen.js文件
2、在screen.js中编辑如下代码
import { Dimensions } from 'react-native';
const { width: _width, height: _height } = Dimensions.get('window');
export const w = 1;
export const h = 1;
export const width = _width * w;
export const height = _height * h;
export default {
width, height
};
3、在需要占满屏幕的文件中页面引入width,height就行
import { width, height } from '../utils/screen'; // 根据项目实际地址引入
<View style={{ width, height }}></View>