Skip to content

Commit

Permalink
fix: pxTransform 可能不存在
Browse files Browse the repository at this point in the history
  • Loading branch information
cncolder committed Jun 8, 2020
1 parent dcaeb64 commit f1c50df
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ export interface LoadingProps {
color?: string | number
}

export const Loading: React.FC<LoadingProps> = props => {
const px = Taro.pxTransform || ((p: number) => `${p}px`)

export const Loading: React.FC<LoadingProps> = (props) => {
const { color, size = '' } = props

const loadingSize = typeof size === 'string' ? size : String(size)
const sizeStyle = {
width: size ? `${Taro.pxTransform(parseInt(loadingSize))}` : '',
height: size ? `${Taro.pxTransform(parseInt(loadingSize))}` : '',
width: size ? `${px(parseInt(loadingSize))}` : '',
height: size ? `${px(parseInt(loadingSize))}` : '',
}
const colorStyle = {
border: color ? `1px solid ${color}` : '',
'border-color': color ? `${color} transparent transparent transparent` : '',
borderColor: color ? `${color} transparent transparent transparent` : '',
}
const ringStyle = { ...colorStyle, ...sizeStyle }

Expand Down

0 comments on commit f1c50df

Please sign in to comment.