diff --git a/components/custom-tabs.vue b/components/custom-tabs.vue index 06cd830..04c248e 100644 --- a/components/custom-tabs.vue +++ b/components/custom-tabs.vue @@ -27,10 +27,18 @@ export default { }, data() { return { - activeIndex: this.current, - targetScrollId: `tab-${this.current}`, // 核心变量:控制scroll-into-view的目标id + // activeIndex: this.current, // 改用computed计算属性 + // targetScrollId: `tab-${this.current}`, // 核心变量:控制scroll-into-view的目标id(改用computed计算属性) }; }, + computed: { + activeIndex() { + return this.current; + }, + targetScrollId() { + return `tab-${this.current}`; + }, + }, methods: { // 点击tab切换(核心:通过变量赋值控制滚动) handleTabClick(index) { diff --git a/pages/home/index.vue b/pages/home/index.vue index 78b7a4d..0c65746 100644 --- a/pages/home/index.vue +++ b/pages/home/index.vue @@ -617,6 +617,7 @@ export default { } else { that.tabInfo.active = 1; } + console.log('that.tabInfo.active',that.tabInfo.active); callback(); }); },