uniapp view高度铺满全屏解决方案 - 100%高度设置技巧
在uniapp中,如果想让view高度铺满全屏,可以使用以下方法:
- 在app.vue或者页面的vue文件中,设置页面的样式为100%高度:
<style> page { height: 100vh; } </style> - 在view的样式中,使用`height: 100vh`来设置高度为100%:
<view class='center'> <view style='background-color: blue; height: 100vh;'>居中文字1</view> <view style='background-color: yellow; height: 100vh;'>居中文字2</view> </view>
这样设置后,view的高度就会铺满全屏了。
以下是示例代码:
<template>
<view class='center'>
<view style='background-color: blue; height: 100vh;'>居中文字1</view>
<view style='background-color: yellow; height: 100vh;'>居中文字2</view>
</view>
</template>
<style>
.center {
height: 100%;
flex: auto;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: red;
}
</style>
原文地址: https://www.cveoy.top/t/topic/AM3 著作权归作者所有。请勿转载和采集!