关于uniapp 全屏尺寸适配

s获取屏幕高度

onReady() {
    uni.getSystemInfo({
        success(res) {
            let screenHeight = res.screenHeight
            let height = ''
            //.box获取class为box的元素,如果使用的id= 'box' 则使用'#box'
            uni.createSelectorQuery().select('.padingLR_1rem').boundingClientRect(data => {
                console.log('data.height',data.height);
                height = screenHeight - data.height
                console.log(height)
            }).exec()
        }
    })
},

image-20240119115345010

我这里使用的机型是

image-20240119115417182

转化为 rpx 比 1:2

所以计算出来全屏100rpx

image-20240119115520658

<template>
	<view>
		<view class="padingLR_1rem padingTB_05rem" style="background-color: #FFFFFF;">
			<u-search placeholder="按台区名称搜索" :animation="true" v-model="queryTaskName" @search="searchTaskName"
				@custom="searchTaskName"></u-search>
		</view>
		<view class="map_content" style="display: flex;flex-direction: column;">
			<map id="myMap" :style="{width: '100%', height: 'calc(100vh - 100rpx)'}" :show-location='true' :latitude="latitude"
				:longitude="longitude" :markers="marker" :scale="scale"></map>
			<view class="showDeviceListCard" style=""></view>
		</view>
		
	</view>
</template>

calc(100vh - 100rpx) 用来计算很适合。

上面主要俩个模块 一个搜索一个地图;高度占比 为100vh即可

实例:

image-20240119120118772

image-20240119120139987

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值