From 0ccbb3f31c4d7711459bf847157b7790279c799e Mon Sep 17 00:00:00 2001 From: fifteen <2329473004@qq.com> Date: Sat, 23 Mar 2024 17:55:06 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96`size`=E8=87=AA?= =?UTF-8?q?=E9=80=82=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ReSegmented/src/index.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/ReSegmented/src/index.tsx b/src/components/ReSegmented/src/index.tsx index 65741ab9e..83f699dd2 100644 --- a/src/components/ReSegmented/src/index.tsx +++ b/src/components/ReSegmented/src/index.tsx @@ -92,11 +92,15 @@ export default defineComponent({ }); } - useResizeObserver(".pure-segmented", () => { - nextTick(() => { - handleInit(curIndex.value); + function handleResizeInit() { + useResizeObserver(".pure-segmented", () => { + nextTick(() => { + handleInit(curIndex.value); + }); }); - }); + } + + props.block && handleResizeInit(); watch( () => curIndex.value, @@ -111,6 +115,11 @@ export default defineComponent({ } ); + watch(() => props.size, handleResizeInit, { + deep: true, + immediate: true + }); + const rendLabel = () => { return props.options.map((option, index) => { return (