From be519115cbc6dbc2c65bd5ea3a896b7ca2bf2641 Mon Sep 17 00:00:00 2001 From: JackySoft Date: Sun, 1 Sep 2024 21:54:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E4=B8=AD=E5=8D=95=E4=BD=8D=E5=9B=9E=E6=98=BE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/editor/src/components/StyleConfig/InputPx.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/editor/src/components/StyleConfig/InputPx.tsx b/packages/editor/src/components/StyleConfig/InputPx.tsx index 54b9dc3..54e3d23 100644 --- a/packages/editor/src/components/StyleConfig/InputPx.tsx +++ b/packages/editor/src/components/StyleConfig/InputPx.tsx @@ -6,8 +6,12 @@ const InputPx = ({ value, onChange, ...props }: any) => { const [unit, setUnit] = useState('px'); useEffect(() => { - const num = value?.toString().replace(/(px|%|vw|vh|rem|em)/, ''); + const val = value?.toString(); + const num = val?.replace(/(px|%|vw|vh|em)/, ''); if (num) setNum(num); + const reg = new RegExp('(px|%|vw|vh|em)'); + const unit = val?.match(reg); + if (unit) setUnit(unit[0]); }, [value]); // 输入框改变 @@ -28,13 +32,12 @@ const InputPx = ({ value, onChange, ...props }: any) => { }; const selectAfter = ( - - );