Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taro v3.1.0-beta.4 js使用Taro.pxTransform动态设置值之后小程序和h5的单位都是px而不是对应的rpx和rem #8507

Closed
Mar-er opened this issue Jan 12, 2021 · 2 comments
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@Mar-er
Copy link

Mar-er commented Jan 12, 2021

相关平台

微信小程序

小程序基础库: 2.14.3
使用框架: React

复现步骤

<View style={{
height: Taro.pxTransform(10)
}}

期望结果

小程序和h5转码之后的单位分别为rpx和rem

实际结果

转码之后的单位都为px

环境信息

Taro v3.1.0-beta.4
  Taro CLI 3.1.0-beta.4 environment info:
    System: OS: Windows 10
    Binaries: Node: 14.15.0 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.10 - C:\Program Files\nodejs\yarn.CMD
      npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD  
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Jan 12, 2021
@Chen-jj Chen-jj added this to the 3.1.0 milestone Jan 13, 2021
@wangfandev
Copy link

@taro -bot2 是所有小程序转换都有问题吗??

@Chen-jj
Copy link
Contributor

Chen-jj commented Jan 26, 2021

@Mar-er 复现不了,你在开发者工具看到的 px 是 rpx 计算后的实际值,style 其实是设置正确了 rpx 的。

export default class Index extends Component {
  render () {
    console.log('Taro.pxTransform(10): ', Taro.pxTransform(10, 375))
    return (
      <View>
        <View
          style={{
            height: Taro.pxTransform(10, 375)
          }}
        />
      </View>
    )
  }
}

小程序:

image

image

image

H5:

image

@Chen-jj Chen-jj closed this as completed Jan 26, 2021
@Chen-jj Chen-jj removed this from the 3.1.0 milestone Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

3 participants