fix(h5): 修复移动端页面整页可滚动与 iOS 橡皮筋问题

This commit is contained in:
bootx
2026-07-20 21:04:29 +08:00
parent 61bb92b7c1
commit 33422b27a9
11 changed files with 23 additions and 15 deletions

View File

@@ -11,9 +11,9 @@ const keepAliveComponents = computed(() => routeStore.keepAliveComponents)
<template>
<div
class="layout-shell h-screen flex flex-col"
class="layout-shell flex flex-col"
>
<RouterView class="flex-1 overflow-x-hidden">
<RouterView class="flex-1 overflow-hidden">
<template #default="{ Component, route }">
<!-- 空数组 [] 仍为 truthy须用 length否则永远走 KeepAlive 分支 -->
<KeepAlive v-if="keepAliveComponents.length" :include="keepAliveComponents">
@@ -28,5 +28,8 @@ const keepAliveComponents = computed(() => routeStore.keepAliveComponents)
<style scoped lang="less">
.layout-shell {
background: var(--h5-bg-page);
// 100dvh 动态视口,地址栏显隐时不再越界;老浏览器回退到 100vh
height: 100vh;
height: 100dvh;
}
</style>

View File

@@ -547,10 +547,8 @@ onUnmounted(() => {
.cashier {
// 三区布局: header 固定 / 中间滚动 / footer 贴底,矮屏不压按钮
height: 100vh;
height: 100dvh;
max-height: 100vh;
max-height: 100dvh;
// 父级 RouterView flex-1 已分配全高,用 100% 严格锁定(避免 100vh/dvh 嵌套溢出)
height: 100%;
background: var(--h5-bg-page);
display: flex;
flex-direction: column;

View File

@@ -105,7 +105,6 @@ onMounted(() => {
<style scoped lang="less">
.code-pay-page {
min-height: 100%;
min-height: 100dvh;
background: var(--h5-bg-page);
box-sizing: border-box;

View File

@@ -105,7 +105,6 @@ onMounted(() => {
<style scoped lang="less">
.code-pay-page {
min-height: 100%;
min-height: 100dvh;
background: var(--h5-bg-page);
box-sizing: border-box;

View File

@@ -101,7 +101,6 @@ onMounted(() => {
<style scoped lang="less">
.code-pay-dispatch {
min-height: 100%;
min-height: 100dvh;
padding-bottom: 40px;
background: var(--h5-bg-page);
box-sizing: border-box;

View File

@@ -324,7 +324,6 @@ function onPay() {
.code-pay-shell {
min-height: 100%;
min-height: 100dvh;
background: var(--h5-bg-page);
display: flex;
flex-direction: column;
@@ -527,7 +526,7 @@ function onPay() {
// 成功结果态
&__result {
flex: 1;
min-height: 100dvh;
min-height: 0;
display: flex;
flex-direction: column;
align-items: center;

View File

@@ -105,7 +105,6 @@ onMounted(() => {
<style scoped lang="less">
.code-pay-page {
min-height: 100%;
min-height: 100dvh;
background: var(--h5-bg-page);
box-sizing: border-box;

View File

@@ -105,7 +105,6 @@ onMounted(() => {
<style scoped lang="less">
.code-pay-page {
min-height: 100%;
min-height: 100dvh;
background: var(--h5-bg-page);
box-sizing: border-box;

View File

@@ -56,7 +56,8 @@ const titleText = computed(() => {
<style scoped lang="less">
.home {
min-height: 100vh;
// 父级 RouterView 的 flex-1 已分配全高min-height: 100vh 会撑破 flex 容器
height: 100%;
display: flex;
flex-direction: column;
background: var(--h5-bg-page);

View File

@@ -90,14 +90,22 @@ onMounted(load)
<style scoped lang="less">
.protocol-page {
min-height: 100vh;
// 父级 RouterView flex-1 已分配全高;用 height: 100% 严格锁定,配合 body overflow:hidden 不外溢
height: 100%;
background: var(--h5-bg-card);
// 留出固定导航栏高度
padding-top: 46px;
box-sizing: border-box;
display: flex;
flex-direction: column;
}
.protocol-body {
// 内部滚动容器:正文超长时自滚,不冒泡到 body
flex: 1;
min-height: 0;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
padding: 16px;
// 长文阅读行高优化
font-size: 15px;

View File

@@ -2,6 +2,10 @@ body,
html {
height: 100%;
width: 100%;
// 阻断 body 滚动(防 iOS Safari 橡皮筋 / 整页空滚)
overflow: hidden;
// 阻断下拉刷新 / 边界回弹
overscroll-behavior: none;
}
#app,