From 219712c3e8cc3c529a8d11e5ffa83166cad4025c Mon Sep 17 00:00:00 2001 From: wangxia <779219182@qq.com> Date: Tue, 31 Mar 2026 10:04:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/custom-tabs.vue | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/components/custom-tabs.vue b/components/custom-tabs.vue index 04c248e..72cd191 100644 --- a/components/custom-tabs.vue +++ b/components/custom-tabs.vue @@ -27,17 +27,13 @@ export default { }, data() { return { - // activeIndex: this.current, // 改用computed计算属性 - // targetScrollId: `tab-${this.current}`, // 核心变量:控制scroll-into-view的目标id(改用computed计算属性) + targetScrollId: `tab-${this.current}`, // 核心变量:控制scroll-into-view的目标id }; }, computed: { activeIndex() { return this.current; }, - targetScrollId() { - return `tab-${this.current}`; - }, }, methods: { // 点击tab切换(核心:通过变量赋值控制滚动) @@ -45,7 +41,7 @@ export default { if (this.activeIndex === index) return; this.activeIndex = index; this.$emit("change", index); - + console.log(); // 计算要滚动到的目标id,让相邻tab显示到可视区 this.calcTargetScrollId(index); },