From 933c2b1da09740cb993726f387bcb6ffa74d9b0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=A6=82=E6=91=B8=E9=B1=BC=E5=8E=BB?= <1780903673@qq.com> Date: Sun, 24 Nov 2024 14:12:28 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E2=99=BB=EF=B8=8F=20=20Tabs=20?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=BF=80=E6=B4=BB=E9=A1=B9=E6=96=B9=E6=B3=95?= =?UTF-8?q?setActive=E8=B0=83=E6=95=B4=E4=B8=BA=E7=AB=8B=E5=8D=B3=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=20(#733)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wot-design-uni/components/wd-tabs/wd-tabs.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue b/src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue index cd763d9e..df936e1d 100644 --- a/src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue +++ b/src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue @@ -219,7 +219,7 @@ const updateActive = (value: number | string = 0, init: boolean = false, setScro * @param {String |Number } value - radio绑定的value或者tab索引,默认值0 * @param {Boolean } init - 是否伴随初始化操作 */ -const setActive = debounce(updateActive, 100, { leading: false }) +const setActive = debounce(updateActive, 100, { leading: true }) watch( () => props.modelValue, @@ -310,7 +310,6 @@ async function updateLineStyle(animation: boolean = true) { if (!state.inited) return const { autoLineWidth, lineWidth, lineHeight } = props try { - const rects = await getRect($item, true, proxy) const lineStyle: CSSProperties = {} if (isDef(lineWidth)) { lineStyle.width = addUnit(lineWidth) @@ -325,12 +324,13 @@ async function updateLineStyle(animation: boolean = true) { lineStyle.height = addUnit(lineHeight) lineStyle.borderRadius = `calc(${addUnit(lineHeight)} / 2)` } + const rects = await getRect($item, true, proxy) const rect = rects[state.activeIndex] let left = rects.slice(0, state.activeIndex).reduce((prev, curr) => prev + Number(curr.width), 0) + Number(rect.width) / 2 if (left) { lineStyle.transform = `translateX(${left}px) translateX(-50%)` if (animation) { - lineStyle.transition = 'width 300ms ease, transform 300ms ease' + lineStyle.transition = 'width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);' } state.useInnerLine = false state.lineStyle = objToStyle(lineStyle)