当前位置:网站首页>uniapp中的view高度设置100%
uniapp中的view高度设置100%
2022-08-05 10:26:00 【spring-java】
1、在APP.vue文件添加如下代码
<script>
export default {
data() {
return {
globalData: {},
}
},
onLaunch: function() {
console.log('App Launch')
uni.getSystemInfo({ //设置屏幕高度
success: res => {
//减去tabbar的高度,默认为50px
this.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>
边栏推荐
- Opencv图像缩放和平移
- 开发常用手册链接分享
- Handwriting Currying - toString Comprehension
- Login function and logout function (St. Regis Takeaway)
- 牛刀小试基本语法,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang基本语法和变量的使用EP02
- [Android]如何使用RecycleView in Kotlin project
- 【MindSpore Easy-Diantong Robot-01】You may have seen many knowledge quiz robots, but this one is a bit different
- Is digital transformation a business buy-in?
- Jenkins manual (2) - software configuration
- RT-Thread记录(一、RT-Thread 版本、RT-Thread Studio开发环境 及 配合CubeMX开发快速上手)
猜你喜欢
随机推荐
Huawei's lightweight neural network architecture GhostNet has been upgraded again, and G-GhostNet (IJCV22) has shown its talents on the GPU
【 temperature warning program DE development 】 event driven model instance
攻防世界-PWN-new_easypwn
High-quality DeFi application building guide to help developers enjoy DeFi Summer
Score interview (1)----related to business
Introduction to SD NAND Flash!
高质量 DeFi 应用构建指南,助力开发者玩转 DeFi Summer
2022华数杯数学建模思路分析交流
DFINITY 基金会创始人谈熊市沉浮,DeFi 项目该何去何从
第四章:activiti流程中,变量的传递和获取流程变量 ,设置和获取多个流程变量,设置和获取局部流程变量「建议收藏」
Use KUSTO query statement (KQL) to query LOG on Azure Data Explorer Database
首次去中心化抢劫?近2亿美元损失:跨链桥Nomad 被攻击事件分析
js hijacks the array push method
阿里全新推出:微服务突击手册,把所有操作都写出来了PDF
一文道清什么是SPL
登录功能和退出功能(瑞吉外卖)
Oracle 19.3 restart 环境
【温度预警程序de开发】事件驱动模型实例运用
Getting started with Polkadot parachain development, this article is enough
第八章:activiti多用户任务分配


![[强网杯2022]WP-UM](/img/3d/caeab05ddca278af274dbf6e2f8ba1.png)






