From fb7cba06c167d49b308b4f92a984906a2444fa6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com> Date: Fri, 28 Feb 2025 11:49:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9rpx=E5=92=8Cpx=E7=9A=84?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 6 +++++- components/diy/tabs-carousel.vue | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/App.vue b/App.vue index d98ff277..ab8c9c07 100644 --- a/App.vue +++ b/App.vue @@ -1914,7 +1914,11 @@ }, // px转rpx px_to_rpx(value) { - return (value || 0) == 0 ? 0 : (parseInt(value) * 750) / parseInt(this.get_system_info('windowWidth', 0)); + const new_value = value * 2 || 0; + // 200 为 100px 的值,后面的两个 100 为计算比例使用 + var rpx = new_value / (uni.upx2px(value) / value); + // 验证上面rpx的值 + return uni.upx2px(rpx); }, // 终端类型 diff --git a/components/diy/tabs-carousel.vue b/components/diy/tabs-carousel.vue index 22ec5672..5de41101 100644 --- a/components/diy/tabs-carousel.vue +++ b/components/diy/tabs-carousel.vue @@ -173,6 +173,10 @@ swiper_bg_style: this.get_swiper_bg_style(new_content, 0), swiper_bg_img_style: this.get_swiper_bg_img_style(new_content, 0), }); + console.log( + app.globalData.px_to_rpx(100) + ); + }, // tab点击 tabs_click_event(tabs_id, is_micro_page) {