【发布时间】:2021-11-26 12:31:24
【问题描述】:
我需要将样式大小更改为 3 种不同的大小,例如宽度
我尝试将条件样式表设为
{const width = useWindowDimensions().width;
//Codes
...}
if( 0 <= width <= 520) {
const styles = StyleSheet.create({
container: {
width: '%100',
},
}
else if ( 521 <= width <= 768) {
const styles = StyleSheet.create({
container: {
width: '%70',
},
}
else {
const styles = StyleSheet.create({
container: {
width: '%50',
},
}
我怎样才能进行这样的操作?有没有更好的办法?
【问题讨论】:
标签: react-native conditional-statements screen-size react-native-stylesheet