perf: 优化size自适应

This commit is contained in:
fifteen 2024-03-23 17:55:06 +08:00
parent bd2c0cba65
commit 0ccbb3f31c

View File

@ -92,11 +92,15 @@ export default defineComponent({
}); });
} }
useResizeObserver(".pure-segmented", () => { function handleResizeInit() {
nextTick(() => { useResizeObserver(".pure-segmented", () => {
handleInit(curIndex.value); nextTick(() => {
handleInit(curIndex.value);
});
}); });
}); }
props.block && handleResizeInit();
watch( watch(
() => curIndex.value, () => curIndex.value,
@ -111,6 +115,11 @@ export default defineComponent({
} }
); );
watch(() => props.size, handleResizeInit, {
deep: true,
immediate: true
});
const rendLabel = () => { const rendLabel = () => {
return props.options.map((option, index) => { return props.options.map((option, index) => {
return ( return (