Skip to content

Commit c42ef04

Browse files
committed
chore: 判断条件采用公共方法
1 parent a56beac commit c42ef04

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/utils/px-transform.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
import Taro, { pxTransform as transform } from '@tarojs/taro'
1+
import { pxTransform as transform } from '@tarojs/taro'
2+
import { harmony, rn } from './platform-taro'
23

34
export default function pxTransform(value: number) {
4-
const isHarmony = [
5-
Taro.ENV_TYPE.HARMONY,
6-
Taro.ENV_TYPE.HARMONYHYBRID,
7-
// @ts-ignore
8-
].includes(Taro.getEnv())
9-
10-
if (isHarmony) return transform(value)
11-
return value
5+
if (harmony() && rn()) return transform(value)
6+
return `${value}px`
127
}

0 commit comments

Comments
 (0)