npmchenwei111
Version:
test1111
26 lines (19 loc) • 464 B
JavaScript
/**
* Created by ziyu on 2017/6/19.
*/
import { Dimensions } from 'react-native'
const deviceH = Dimensions.get('window').height
const deviceW = Dimensions.get('window').width
const basePx = 375
export function px (px) {
if (px == null) return 0
return px * deviceW / basePx
}
export function sp (sp) {
if (sp == null) return 0
return sp * deviceW / basePx
}
export function px2dp (px) {
if (px == null) return 0
return px * deviceW / basePx
}