Spaces:
Running
Running
| <script setup lang="ts"> | |
| import { onLaunch, onShow, onHide } from "@dcloudio/uni-app"; | |
| onLaunch(() => { | |
| console.log("App Launch"); | |
| }); | |
| onShow(() => { | |
| console.log("App Show"); | |
| }); | |
| onHide(() => { | |
| console.log("App Hide"); | |
| }); | |
| </script> | |
| <style lang="scss"> | |
| /* H5 网页全局布局优化:严格模拟手机端居中显示 */ | |
| /* #ifdef H5 */ | |
| html, | |
| body { | |
| background-color: #f5f5f5 ; | |
| height: 100%; | |
| overflow: hidden; /* 禁止最外层 body 滚动 */ | |
| } | |
| uni-app { | |
| max-width: 450px ; | |
| height: 100% ; | |
| margin: 0 auto ; | |
| box-shadow: 0 0 20px rgba(0, 0, 0, 0.1); | |
| background-color: #fff; | |
| display: flex; | |
| flex-direction: column; | |
| position: relative; | |
| overflow: hidden; /* 内部容器自包含 */ | |
| } | |
| /* 头部导航栏:强制居中且宽度一致 */ | |
| uni-page-head { | |
| max-width: 450px ; | |
| left: 0 ; | |
| right: 0 ; | |
| margin: 0 auto ; | |
| position: fixed ; | |
| z-index: 999; | |
| } | |
| /* 底部 TabBar:强制居中且宽度一致 */ | |
| uni-tabbar { | |
| max-width: 450px ; | |
| left: 0 ; | |
| right: 0 ; | |
| margin: 0 auto ; | |
| position: fixed ; | |
| z-index: 999; | |
| /* 针对 uni-tabbar 内部容器的特殊处理,防止内容溢出 */ | |
| .uni-tabbar { | |
| max-width: 450px ; | |
| margin: 0 auto ; | |
| left: 0 ; | |
| right: 0 ; | |
| } | |
| } | |
| /* 内容区域:允许内部滚动,解决无内容却能滚动的问题 */ | |
| uni-page-wrapper { | |
| background-color: #fff ; | |
| height: 100% ; | |
| overflow-y: auto ; /* 只在内容区允许滚动 */ | |
| -webkit-overflow-scrolling: touch; | |
| } | |
| /* 隐藏滚动条 */ | |
| ::-webkit-scrollbar { | |
| display: none; | |
| width: 0 ; | |
| height: 0 ; | |
| } | |
| /* 修复标题栏显示 */ | |
| .uni-page-head-bd { | |
| font-size: 16px ; | |
| font-weight: bold ; | |
| } | |
| /* #endif */ | |
| </style> | |