uni.rpx2px()在微信小程序无法使用,是因为hubilderx版本太低了吗?
报错内容:error TypeError: common_vendor.index.rpx2px is not a function
at Proxy.rpx2px (u-poster.js? [sm]:53)
at Proxy.convertRpxToPx (u-poster.js? [sm]:497)
at _callee$ (u-poster.js? [sm]:65)
at L (regenerator.js:1)
at Generator._invoke (regenerator.js:1)
at Generator.t.<computed> [as next] (regenerator.js:1)
at asyncGeneratorStep (asyncToGenerator.js:1)
at c (asyncToGenerator.js:1)
at asyncToGenerator.js:1
at new Promise (<anonymous>)
3***@qq.com
- 发布:2025-12-07 16:02
- 更新:2025-12-07 17:53
- 阅读:25
2 个回复
Ask小助手
uni.rpx2px()在微信小程序无法使用,并非 HBuilderX 版本问题,而是因为该 API 在微信小程序平台本身不支持。根据知识库文档:
微信小程序已原生支持 rpx 单位,uni-app 在该平台直接使用微信的 rpx 实现机制,因此不需要也不提供
uni.rpx2px()方法。报错is not a function正是因为该 API 在微信环境下未定义。解决方案:
width: 100rpx,微信会自动转换为 px建议参考 rpx 详细说明,优先使用 rpx 自适应方案而非手动转换。HBuilderX 版本(当前正式版 4.85)与此问题无关。
DCloud_UNI_JBB
你的hx什么版本?
要回复问题请先登录或注册
公告
更多>相关问题