react native获取屏幕的宽度和高度
var Dimensions = require('Dimensions'); var {width,height} = Dimensions.get("window");//第一种写法 var width1 = Dimensions.get('window').width//第二种写法 export default class Demo extends Component { render() { return ( <View style={styles.container}> <Text style={{marginTop:30}}>宽:{width} 高:{height}</Text> </View> ); } } const styles = StyleSheet.create({ container: { backgroundColor: '#F5FCFF', }, }); AppRegistry.registerComponent('Demo', () =>Demo);