作者:看非诚勿扰是修炼 | 来源:互联网 | 2022-12-04 10:48
我正在使用React Native
带有徽标和2个输入的基本登录名:
//import liraries
import React, { Component } from 'react';
import { View, Text, StyleSheet, Image } from 'react-native';
// create a component
class Login extends Component {
render() {
const imageURL = require('./images/CircleLogo.png');
return (
);
}
}
// define your styles
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'aliceblue',
},
loginContainer:{
alignItems: 'center',
flexGrow: 1,
justifyContent: 'center'
},
logo: {
position: 'absolute',
width: '70vw',
height: '70vw',
maxWidth: 300
}
});
//make this component available to the app
export default Login;
如您所见,我正在使用vw
和vh
CSS测量。
这在网络上有效,但在iOS或Android上无效。
有人对处理vw
和vh
测量有很好的建议吗?
边注:这似乎反应过来接受所看到的百分比在这里,我可以恢复。但是我的问题专门涉及vw
和vh
测量。
1> 小智..:
视口单位:vw,vh,vmin,vmax-React Native。
https://github.com/joetakara/react-native-expo-viewport-units
安装
npm install react-native-expo-viewport-units
要么
yarn add react-native-expo-viewport-units
用法
import { vw, vh, vmin, vmax } from 'react-native-expo-viewport-units';
...