File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ pub fn generate_expr_by_length_value(length_value: &LengthValue, platform: Platf
145145
146146pub fn generate_expr_with_css_input ( input : String , platform : Platform ) -> Expr {
147147 // 定义匹配 '16px' 的正则表达式
148- let re = Regex :: new ( r"(-?(?P<num>\d+(\.\d*)?|\.\d+))(?P<unit>(px|vw|vh|pX|PX|Px)?)" ) . unwrap ( ) ;
148+ let re = Regex :: new ( r"(-?(?P<num>\d+(\.\d*)?|\.\d+))(?P<unit>(%| px|vw|vh|pX|PX|Px)?)" ) . unwrap ( ) ;
149149 let bytes = input. as_bytes ( ) ;
150150 // 使用正则表达式进行匹配
151151 if let Ok ( caps) = re. captures ( bytes) {
@@ -171,6 +171,9 @@ pub fn generate_expr_with_css_input(input: String, platform: Platform) -> Expr {
171171 "pX" | "PX" | "Px" => {
172172 return generate_expr_lit_str ! ( format!( "{}px" , number) )
173173 } ,
174+ "%" => {
175+ return generate_expr_lit_str ! ( format!( "{}%" , number) )
176+ }
174177 _ => {
175178 // 如果没有单位,则认为是纯数字,返回 Expr::Num
176179 return generate_expr_lit_num ! ( number) ;
You can’t perform that action at this time.
0 commit comments