rn 获取屏幕高宽

引入Dimensions
	
通过Dimensions.get("window").width/height; 获取屏幕高宽

代码示例:

import React,{Component} from 'react'
import {Text,View,ScrollView,StyleSheet, Alert,Dimensions} from 'react-native'

export default class App extends Component{

    componentDidMount(){
        const { width, height } = Dimensions.get('window');
        
    }
    render(){
        return(
            <>
                <View>
                    
                </View>
            </>
        )
    }

}
发布了619 篇原创文章 · 获赞 3 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/weixin_43294560/article/details/105180328
RN