Skip to content
This repository has been archived by the owner on Dec 6, 2021. It is now read-only.

Commit

Permalink
fix(utils): pxTransform failed to handle h5
Browse files Browse the repository at this point in the history
  • Loading branch information
b2nil committed Oct 24, 2020
1 parent eb553c9 commit 68dd196
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@ const getEnvs = (): ENVS => {
}
}

function pxTransform(size: number): string {
function pxTransform(size: number, designWidth?: number): string {
if (!size) return ''

const designWidth = 750
const deviceRatio = {
640: 2.34 / 2,
750: 1,
828: 1.81 / 2,
if (!designWidth) {
designWidth = 750
}

return `${size / deviceRatio[designWidth]}rpx`
return Taro.pxTransform(size, designWidth)
}

function delay(delayTime = 500): Promise<null> {
Expand Down

0 comments on commit 68dd196

Please sign in to comment.