Commit 9cc0b1f 1 parent fc17b58 commit 9cc0b1f Copy full SHA for 9cc0b1f
File tree 1 file changed +6
-8
lines changed
1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,9 @@ export const extractPropsDefaultValue = (props: { [key: string]: any }) => {
72
72
73
73
// 10px => 10
74
74
export const depx = ( value : string | number ) : number => {
75
+ if ( isUndefined ( value ) || isNull ( value ) ) {
76
+ return undefined ;
77
+ }
75
78
if ( isString ( value ) && value . endsWith ( 'px' ) ) {
76
79
const formatValue = value . slice ( 0 , value . length - 2 ) ;
77
80
if ( isFinite ( Number ( formatValue ) ) ) {
@@ -81,26 +84,21 @@ export const depx = (value: string | number): number => {
81
84
if ( isFinite ( Number ( value ) ) ) {
82
85
return Number ( value ) ;
83
86
}
84
-
85
87
console . warn ( '[depx] 转换失败,原始值为:' , value ) ;
86
- if ( isUndefined ( value ) || isNull ( value ) ) {
87
- return undefined ;
88
- }
89
88
return value as number ;
90
89
} ;
91
90
92
91
// 10 => 10px
93
92
export const pxfy = ( value : string | number ) : string => {
93
+ if ( isUndefined ( value ) || isNull ( value ) ) {
94
+ return undefined ;
95
+ }
94
96
if ( isFinite ( value ) ) {
95
97
return `${ value } px` ;
96
98
}
97
99
if ( isFinite ( Number ( value ) ) ) {
98
100
return `${ Number ( value ) } px` ;
99
101
}
100
-
101
- if ( isUndefined ( value ) || isNull ( value ) ) {
102
- return undefined ;
103
- }
104
102
return value as string ;
105
103
} ;
106
104
You can’t perform that action at this time.
0 commit comments