uniapp在app端老是铺满全屏
解决办法:
h5端用style
app端用webview-styles
<template><Wrap><view class="px-[13px]"><NavBar :title="$t('客服')" id="header"></NavBar><view class="scroll-content"><web-view:src="addr":style="{ top: wvTop }"ref="wvRef":webview-styles="{ top: wvTop }"></web-view></view></view></Wrap> </template> <script setup lang="ts"> import NavBar from '@/components/navbar/index.vue' import { nextTick, ref } from 'vue' import { getConfigApi } from '@/api'// 也可链接当前应用的地址 // #/pages/404/index const addr = ref('')getConfigApi({ keyword: 'kf' }).then((res: any) => {const data = res.dataaddr.value = data.kf_url })const wvTop = ref('0px')nextTick(() => {const query = uni.createSelectorQuery()query.select('#header').boundingClientRect((data) => {if (data) {// #ifdef H5wvTop.value = (data.height || 0) + 'px'// #endif// #ifdef APP-PLUSwvTop.value = (data.height || 0) + 30 + 'px'// #endif}}).exec() }) </script><style lang="scss" scoped></style>