Open
Conversation
added 2 commits
March 17, 2026 17:58
2.page → page, :root(CSS 变量 H5 继承) 3.内联样式改用 Taro.pxTransform(),修复堆叠列表
Owner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


修复原因
修复了项目在 H5 编译下与微信小程序产生的多处 UI 不一致问题(如卡片堆叠错乱、背景色丢失、间距异常等)。由于 H5 没有
page元素包装,且原本存在双端单位重复转换等问题,本项目通过适配底层编译组合,实现真正的双端高保真一致。详细改动
unocss.config.ts(解决单位错乱与布局崩溃)postprocess(rem到px硬转),彻底解决了跟 Taro 内部的pxtransform产生的单位二次转换导致间距巨大的问题。presetRemRpx({ mode: isApplet ? "rem2rpx" : "rpx2rem" }),自动处理 H5 与小程序端的环境差异。src/app.scss(解决全局样式、颜色丢失):root选择器作用域。原本是page { ... },修改为page, :root { ... }。确保依赖全局变量(比如--primary-color-6)的样式在 H5 环境下的纯 web 节点下也能正确生效。src/pages/index/index.tsx(解决动态内联样式的平台适配)Taro.pxTransform(70)动态获取内联转换,调整了偏移和比例scale。还原出跟原生小程序端一致的真实层叠感。验证环境与效果
在运行
pnpm dev:h5及微信开发者工具分别观察比对,双端 UI 达到像素级一致,特别是以下组件: