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 (