admin 管理员组

文章数量: 1087748

uniapp中的view高度设置100%

1、在APP.vue文件添加如下代码

<script>export default {data() {return {globalData: {},}},onLaunch: function() {console.log('App Launch')uni.getSystemInfo({ //设置屏幕高度success: res => {//减去tabbar的高度,默认为50pxthis.globalData.screenHeight = res.screenHeight;this.globalData.screenWidth = res.screenWidth;}})},onShow: function() {console.log('App Show')},onHide: function() {console.log('App Hide')}}
</script><style lang="scss">/*每个页面公共css */@import "@/uni_modules/uview-ui/index.scss";
</style>

2、在组件中设置页面高度

<template><view><view class="barClass" :style="'height:'+screenHeight+'px'">左分页</view><view style="width: 70%;float: left;">右分页</view></view></template><script>export default {data() {return {screenHeight: getApp().globalData.screenHeight}},onShow() {plus.screen.lockOrientation('landscape-primary');plus.navigator.setFullscreen(true)},onUnload() {plus.screen.lockOrientation('portrait-primary')plus.navigator.setFullscreen(false)},methods: {}}
</script><style lang="scss" scoped>.barClass {width: 30%;float: left;background-color: #000000;}
</style>

本文标签: uniapp中的view高度设置100